alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Akka/Scala example source code file (Op.java)

This example Akka source code file (Op.java) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Akka and Scala source code examples by using tags.

All credit for the original source code belongs to akka.io; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Akka tags/keywords

add, addresult, akka, divide, divisionresult, mathop, mathresult, multiplicationresult, multiply, remote, serializable, subtractresult

The Op.java Akka example source code

package sample.remote.calculator;

import java.io.Serializable;

public class Op {

  public interface MathOp extends Serializable {
  }

  public interface MathResult extends Serializable {
  }

  static class Add implements MathOp {
    private static final long serialVersionUID = 1L;
    private final int n1;
    private final int n2;

    public Add(int n1, int n2) {
      this.n1 = n1;
      this.n2 = n2;
    }

    public int getN1() {
      return n1;
    }

    public int getN2() {
      return n2;
    }
  }

  static class AddResult implements MathResult {
    private static final long serialVersionUID = 1L;
    private final int n1;
    private final int n2;
    private final int result;

    public AddResult(int n1, int n2, int result) {
      this.n1 = n1;
      this.n2 = n2;
      this.result = result;
    }

    public int getN1() {
      return n1;
    }

    public int getN2() {
      return n2;
    }

    public int getResult() {
      return result;
    }
  }

  static class Subtract implements MathOp {
    private static final long serialVersionUID = 1L;
    private final int n1;
    private final int n2;

    public Subtract(int n1, int n2) {
      this.n1 = n1;
      this.n2 = n2;
    }

    public int getN1() {
      return n1;
    }

    public int getN2() {
      return n2;
    }
  }

  static class SubtractResult implements MathResult {
    private static final long serialVersionUID = 1L;
    private final int n1;
    private final int n2;
    private final int result;

    public SubtractResult(int n1, int n2, int result) {
      this.n1 = n1;
      this.n2 = n2;
      this.result = result;
    }

    public int getN1() {
      return n1;
    }

    public int getN2() {
      return n2;
    }

    public int getResult() {
      return result;
    }
  }

  static class Multiply implements MathOp {
    private static final long serialVersionUID = 1L;
    private final int n1;
    private final int n2;

    public Multiply(int n1, int n2) {
      this.n1 = n1;
      this.n2 = n2;
    }

    public int getN1() {
      return n1;
    }

    public int getN2() {
      return n2;
    }
  }

  static class MultiplicationResult implements MathResult {
    private static final long serialVersionUID = 1L;
    private final int n1;
    private final int n2;
    private final int result;

    public MultiplicationResult(int n1, int n2, int result) {
      this.n1 = n1;
      this.n2 = n2;
      this.result = result;
    }

    public int getN1() {
      return n1;
    }

    public int getN2() {
      return n2;
    }

    public int getResult() {
      return result;
    }
  }

  static class Divide implements MathOp {
    private static final long serialVersionUID = 1L;
    private final double n1;
    private final int n2;

    public Divide(double n1, int n2) {
      this.n1 = n1;
      this.n2 = n2;
    }

    public double getN1() {
      return n1;
    }

    public int getN2() {
      return n2;
    }
  }

  static class DivisionResult implements MathResult {
    private static final long serialVersionUID = 1L;
    private final double n1;
    private final int n2;
    private final double result;

    public DivisionResult(double n1, int n2, double result) {
      this.n1 = n1;
      this.n2 = n2;
      this.result = result;
    }

    public double getN1() {
      return n1;
    }

    public int getN2() {
      return n2;
    }

    public double getResult() {
      return result;
    }
  }
}

Other Akka source code examples

Here is a short list of links related to this Akka Op.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.