Enum 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.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • 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 name
        java.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 input
        b - Second input
        Returns:
        result of applying the operator to a and b
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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