cdx.scorebot.scoring.logic
Enum OperatorType

java.lang.Object
  extended by java.lang.Enum<OperatorType>
      extended by cdx.scorebot.scoring.logic.OperatorType
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<OperatorType>

public enum OperatorType
extends java.lang.Enum<OperatorType>

defines the different kinds of comparison operators

Author:
David Underhill

Enum Constant Summary
AND
           
ASSIGN
           
DIVIDE
           
EQUAL
           
GREATER_THAN
           
GREATER_THAN_OR_EQUAL
           
LESS_THAN
           
LESS_THAN_OR_EQUAL
           
MINUS
           
MOD
           
NEGATION
           
NO_OP
           
NOT_EQUAL
           
OR
           
PLUS
           
TIMES
           
UNARY_MINUS
           
XOR
           
 
Method Summary
static Literal evaluate(Literal o1, OperatorType operator, Literal o2)
          evaluates the specified binary operator on the specified operands
static Literal evaluate(OperatorType operator, Literal o)
          evaluates the specified unary operator on the specified operand
static OperatorType valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static OperatorType[] 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, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

NO_OP

public static final OperatorType NO_OP

ASSIGN

public static final OperatorType ASSIGN

AND

public static final OperatorType AND

OR

public static final OperatorType OR

XOR

public static final OperatorType XOR

PLUS

public static final OperatorType PLUS

MINUS

public static final OperatorType MINUS

TIMES

public static final OperatorType TIMES

DIVIDE

public static final OperatorType DIVIDE

MOD

public static final OperatorType MOD

EQUAL

public static final OperatorType EQUAL

NOT_EQUAL

public static final OperatorType NOT_EQUAL

LESS_THAN

public static final OperatorType LESS_THAN

LESS_THAN_OR_EQUAL

public static final OperatorType LESS_THAN_OR_EQUAL

GREATER_THAN

public static final OperatorType GREATER_THAN

GREATER_THAN_OR_EQUAL

public static final OperatorType GREATER_THAN_OR_EQUAL

UNARY_MINUS

public static final OperatorType UNARY_MINUS

NEGATION

public static final OperatorType NEGATION
Method Detail

values

public static OperatorType[] 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 (OperatorType c : OperatorType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static OperatorType 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

evaluate

public static Literal evaluate(OperatorType operator,
                               Literal o)
                        throws IllegalOperandException,
                               TypeMismatchException
evaluates the specified unary operator on the specified operand

Parameters:
operator - unary operator
o - operand
Throws:
IllegalOperandException - occurs the operand is incompatible with the operator
TypeMismatchException

evaluate

public static Literal evaluate(Literal o1,
                               OperatorType operator,
                               Literal o2)
                        throws TypeMismatchException,
                               IllegalOperandException
evaluates the specified binary operator on the specified operands

Parameters:
o1 - first operand
operator - binary operator
o2 - second operand
Throws:
TypeMismatchException - occurs if o1 and o2 are different, incompatible types
IllegalOperandException - occurs if o1 and o2 are not defined for the specified operator