Class DefaultOperators

java.lang.Object
nz.org.riskscape.engine.rl.DefaultOperators
All Implemented Interfaces:
nz.org.riskscape.engine.function.OperatorResolver

public class DefaultOperators extends Object implements nz.org.riskscape.engine.function.OperatorResolver

Core set of functions that work with the default types in RiskScape - should cover most of what ECQL does.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final EnumSet<nz.org.riskscape.rl.TokenTypes>
     
    static final EnumSet<nz.org.riskscape.rl.TokenTypes>
     
    static final EnumSet<nz.org.riskscape.rl.TokenTypes>
     
    static final DefaultOperators
     
    static final Map<nz.org.riskscape.rl.TokenTypes,List<nz.org.riskscape.engine.function.RiskscapeFunction>>
     
    static final EnumSet<nz.org.riskscape.rl.TokenTypes>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> nz.org.riskscape.engine.function.RiskscapeFunction
    operatorFor(nz.org.riskscape.rl.TokenTypes operationToken, Class<T> javaType, BinaryOperator<T> function)
     
    nz.org.riskscape.engine.function.RiskscapeFunction
    orFunction(boolean nullableInputs)
    Returns a RiskscapeFunction implementing OR logic.
    <T> nz.org.riskscape.engine.function.RiskscapeFunction
    predicateFor(nz.org.riskscape.rl.TokenTypes operator, Class<T> javaType, BiPredicate<T,T> predicate)
     
    Optional<nz.org.riskscape.engine.function.RiskscapeFunction>
    resolve(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.BinaryOperation operation, nz.org.riskscape.engine.types.Type inputType, nz.org.riskscape.engine.types.Type lhs, nz.org.riskscape.engine.types.Type rhs)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MATHS_OPERATORS

      public static final EnumSet<nz.org.riskscape.rl.TokenTypes> MATHS_OPERATORS
    • BOOLEAN_COMPARATORS

      public static final EnumSet<nz.org.riskscape.rl.TokenTypes> BOOLEAN_COMPARATORS
    • EQUALITY_OPERATORS

      public static final EnumSet<nz.org.riskscape.rl.TokenTypes> EQUALITY_OPERATORS
    • BOOLEAN_LOGIC_OPERATORS

      public static final EnumSet<nz.org.riskscape.rl.TokenTypes> BOOLEAN_LOGIC_OPERATORS
    • MATHS_FUNCTIONS

      public static final Map<nz.org.riskscape.rl.TokenTypes,List<nz.org.riskscape.engine.function.RiskscapeFunction>> MATHS_FUNCTIONS
    • INSTANCE

      public static final DefaultOperators INSTANCE
  • Constructor Details

    • DefaultOperators

      public DefaultOperators()
  • Method Details

    • predicateFor

      public <T> nz.org.riskscape.engine.function.RiskscapeFunction predicateFor(nz.org.riskscape.rl.TokenTypes operator, Class<T> javaType, BiPredicate<T,T> predicate)
    • orFunction

      public nz.org.riskscape.engine.function.RiskscapeFunction orFunction(boolean nullableInputs)

      Returns a RiskscapeFunction implementing OR logic.

      If nullableInputs is true, then an exception to the any null input returns null rule (refer to NullSafeFunction) is made and true/false is returned as long as one of the arguments is not null. If both arguments are null then null is returned.

      The function returned by this method should not be wrapped in a NullSafeFunction as that will change the OR logic behaviour with one null argument.

      Parameters:
      nullableInputs - indicates if either input could be null
      Returns:
      or function
    • operatorFor

      public static <T> nz.org.riskscape.engine.function.RiskscapeFunction operatorFor(nz.org.riskscape.rl.TokenTypes operationToken, Class<T> javaType, BinaryOperator<T> function)
    • resolve

      public Optional<nz.org.riskscape.engine.function.RiskscapeFunction> resolve(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.BinaryOperation operation, nz.org.riskscape.engine.types.Type inputType, nz.org.riskscape.engine.types.Type lhs, nz.org.riskscape.engine.types.Type rhs)
      Specified by:
      resolve in interface nz.org.riskscape.engine.function.OperatorResolver