Enum Class ExpressionOperator

java.lang.Object
java.lang.Enum<ExpressionOperator>
generic.expressions.ExpressionOperator
All Implemented Interfaces:
ExpressionElement, Serializable, Comparable<ExpressionOperator>, Constable

public enum ExpressionOperator extends Enum<ExpressionOperator> implements ExpressionElement
Enum of support operators for the ExpressionEvaluator
  • Enum Constant Details

  • Field Details

  • Method Details

    • values

      public static ExpressionOperator[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ExpressionOperator valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • toString

      public String toString()
      Overrides:
      toString in class Enum<ExpressionOperator>
    • getBinaryOperatorsByPrecedence

      public static List<Set<ExpressionOperator>> getBinaryOperatorsByPrecedence()
      Returns a list of all the binary operators in precedence order, organized into sets where each set contains all the operators of the same precedence.
      Returns:
      a list of all the binary operators in precedence order, organized into sets where each set contains all the operators of the same precedence.
    • getOperator

      public static ExpressionOperator getOperator(String token, String lookahead1, boolean preferBinary)
      Returns the operator for the given token and look ahead token and if we are expecting to find a binary operator. This method first tries merging the tokens looking for a double char operator first.
      Parameters:
      token - the first token
      lookahead1 - the next token that may or may not be part of this operand
      preferBinary - if we are expecting a binary operator (the previous expression element was an operand value). We need this to know if the token '-' is the unary operator or the binary operator. If the token before was an operator, then we expect a unary operator. If the previous was a value, then we expect a binary operator.
      Returns:
      the operator that matches the given tokens and expected type
    • size

      public int size()
      Returns the number of chars in the operator
      Returns:
      the number of chars in the operator
    • isUnary

      public boolean isUnary()
      Returns if the operator is a unary operator.
      Returns:
      if the operator is a unary operator.
    • isBinary

      public boolean isBinary()
      Returns if the operator is a binary operator.
      Returns:
      if the operator is a binary operator.