Enum Op2
- java.lang.Object
-
- java.lang.Enum<Op2>
-
- org.protelis.lang.interpreter.util.Op2
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Op2>
,WithBytecode
public enum Op2 extends java.lang.Enum<Op2> implements WithBytecode
Infix operator that takes two inputs, such as addition, division, or "greater than" comparison.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description AND
Logical AND operation.DIFFERS
Inequality comparison operation.DIVIDE
Arithmetic division operation.EQUALS
Equality comparison operation.GREATER
Greater-than comparison operation.GREATER_EQUAL
Greater-than-or-equal comparison operation.MAX
Maximum of two numbers or other Comparable objects.MIN
Minimum of two numbers or other Comparable objects.MINUS
Arithmetic subtraction operation.MODULUS
Modulus operation.OR
Logical OR operation.PLUS
Arithmetic addition operation.POWER
Exponent operation.SMALLER
Less-than comparison operation.SMALLER_EQUAL
Less-than-or-equal comparison operation.TIMES
Arithmetic multiplication operation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Bytecode
getBytecode()
java.util.function.BinaryOperator<java.lang.Object>
getFunction()
static Op2
getOp(java.lang.String name)
Translates a name into an operator.java.lang.Object
run(java.lang.Object a, java.lang.Object b)
Compute the value of applying the two-argument operator to inputs a and b.java.lang.String
toString()
static Op2
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static Op2[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
AND
public static final Op2 AND
Logical AND operation.
-
DIFFERS
public static final Op2 DIFFERS
Inequality comparison operation.
-
DIVIDE
public static final Op2 DIVIDE
Arithmetic division operation.
-
EQUALS
public static final Op2 EQUALS
Equality comparison operation.
-
GREATER
public static final Op2 GREATER
Greater-than comparison operation.
-
GREATER_EQUAL
public static final Op2 GREATER_EQUAL
Greater-than-or-equal comparison operation.
-
MAX
public static final Op2 MAX
Maximum of two numbers or other Comparable objects.
-
MIN
public static final Op2 MIN
Minimum of two numbers or other Comparable objects.
-
MINUS
public static final Op2 MINUS
Arithmetic subtraction operation.
-
MODULUS
public static final Op2 MODULUS
Modulus operation.
-
OR
public static final Op2 OR
Logical OR operation.
-
PLUS
public static final Op2 PLUS
Arithmetic addition operation.
-
POWER
public static final Op2 POWER
Exponent operation.
-
SMALLER
public static final Op2 SMALLER
Less-than comparison operation.
-
SMALLER_EQUAL
public static final Op2 SMALLER_EQUAL
Less-than-or-equal comparison operation.
-
TIMES
public static final Op2 TIMES
Arithmetic multiplication operation.
-
-
Method Detail
-
values
public static Op2[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Op2 c : Op2.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Op2 valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getFunction
public java.util.function.BinaryOperator<java.lang.Object> getFunction()
- Returns:
- The function implementing this operator
-
run
public java.lang.Object run(java.lang.Object a, java.lang.Object b)
Compute the value of applying the two-argument operator to inputs a and b.- Parameters:
a
- First inputb
- Second input- Returns:
- result of applying the operator to a and b
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Enum<Op2>
-
getOp
public static Op2 getOp(java.lang.String name)
Translates a name into an operator.- Parameters:
name
- operator name- Returns:
- an
Op2
-
getBytecode
public Bytecode getBytecode()
- Specified by:
getBytecode
in interfaceWithBytecode
- Returns:
- the element
Bytecode
-
-