Class ExpressionUtils

java.lang.Object
me.hsgamer.hscore.expression.ExpressionUtils

public final class ExpressionUtils extends Object
The expression manager
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.ezylang.evalex.Expression
    Create an expression
    static com.ezylang.evalex.Expression
    createExpression(String expression, com.ezylang.evalex.config.ExpressionConfiguration expressionConfiguration)
    Create an expression
    static com.ezylang.evalex.data.EvaluationValue
    evaluate(String expression)
    Evaluate the expression
    static com.ezylang.evalex.data.EvaluationValue
    evaluate(String expression, com.ezylang.evalex.config.ExpressionConfiguration expressionConfiguration)
    Evaluate the expression
    static com.ezylang.evalex.data.EvaluationValue
    evaluate(String expression, com.ezylang.evalex.config.ExpressionConfiguration expressionConfiguration, Map<String,Object> values)
    Evaluate the expression
    static com.ezylang.evalex.data.EvaluationValue
    evaluate(String expression, Map<String,Object> values)
    Evaluate the expression
    static Optional<com.ezylang.evalex.data.EvaluationValue>
    evaluateSafe(String expression)
    Evaluate the expression
    static Optional<com.ezylang.evalex.data.EvaluationValue>
    evaluateSafe(String expression, com.ezylang.evalex.config.ExpressionConfiguration expressionConfiguration)
    Evaluate the expression
    static Optional<com.ezylang.evalex.data.EvaluationValue>
    evaluateSafe(String expression, com.ezylang.evalex.config.ExpressionConfiguration expressionConfiguration, Map<String,Object> values)
    Evaluate the expression
    static Optional<com.ezylang.evalex.data.EvaluationValue>
    evaluateSafe(String expression, Map<String,Object> values)
    Evaluate the expression
    static com.ezylang.evalex.config.ExpressionConfiguration
    Get the default expression configuration
    static Function<com.ezylang.evalex.config.ExpressionConfiguration,com.ezylang.evalex.config.ExpressionConfiguration>
    Get the expression configuration modifier
    static void
    registerFunction(String name, com.ezylang.evalex.functions.FunctionIfc function)
    Register a function
    static void
    registerOperator(String name, com.ezylang.evalex.operators.OperatorIfc operator)
    Register an operator

    Methods inherited from class java.lang.Object

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

    • registerFunction

      public static void registerFunction(String name, com.ezylang.evalex.functions.FunctionIfc function)
      Register a function
      Parameters:
      name - the name of the function
      function - the function
    • registerOperator

      public static void registerOperator(String name, com.ezylang.evalex.operators.OperatorIfc operator)
      Register an operator
      Parameters:
      name - the name of the operator
      operator - the operator
    • getExpressionConfigurationModifier

      public static Function<com.ezylang.evalex.config.ExpressionConfiguration,com.ezylang.evalex.config.ExpressionConfiguration> getExpressionConfigurationModifier()
      Get the expression configuration modifier
      Returns:
      the expression configuration modifier
    • getDefaultExpressionConfiguration

      public static com.ezylang.evalex.config.ExpressionConfiguration getDefaultExpressionConfiguration()
      Get the default expression configuration
      Returns:
      the expression configuration
    • createExpression

      public static com.ezylang.evalex.Expression createExpression(String expression, com.ezylang.evalex.config.ExpressionConfiguration expressionConfiguration)
      Create an expression
      Parameters:
      expression - the expression
      expressionConfiguration - the expression configuration
      Returns:
      the expression
    • createExpression

      public static com.ezylang.evalex.Expression createExpression(String expression)
      Create an expression
      Parameters:
      expression - the expression
      Returns:
      the expression
    • evaluate

      public static com.ezylang.evalex.data.EvaluationValue evaluate(String expression, com.ezylang.evalex.config.ExpressionConfiguration expressionConfiguration) throws com.ezylang.evalex.EvaluationException, com.ezylang.evalex.parser.ParseException
      Evaluate the expression
      Parameters:
      expression - the expression
      expressionConfiguration - the expression configuration
      Returns:
      the result
      Throws:
      com.ezylang.evalex.EvaluationException - occurred when evaluating
      com.ezylang.evalex.parser.ParseException - if the expression is invalid
    • evaluate

      public static com.ezylang.evalex.data.EvaluationValue evaluate(String expression, com.ezylang.evalex.config.ExpressionConfiguration expressionConfiguration, Map<String,Object> values) throws com.ezylang.evalex.EvaluationException, com.ezylang.evalex.parser.ParseException
      Evaluate the expression
      Parameters:
      expression - the expression
      expressionConfiguration - the expression configuration
      values - the values
      Returns:
      the result
      Throws:
      com.ezylang.evalex.EvaluationException - occurred when evaluating
      com.ezylang.evalex.parser.ParseException - if the expression is invalid
    • evaluate

      public static com.ezylang.evalex.data.EvaluationValue evaluate(String expression, Map<String,Object> values) throws com.ezylang.evalex.EvaluationException, com.ezylang.evalex.parser.ParseException
      Evaluate the expression
      Parameters:
      expression - the expression
      values - the values
      Returns:
      the result
      Throws:
      com.ezylang.evalex.EvaluationException - occurred when evaluating
      com.ezylang.evalex.parser.ParseException - if the expression is invalid
    • evaluate

      public static com.ezylang.evalex.data.EvaluationValue evaluate(String expression) throws com.ezylang.evalex.EvaluationException, com.ezylang.evalex.parser.ParseException
      Evaluate the expression
      Parameters:
      expression - the expression
      Returns:
      the result
      Throws:
      com.ezylang.evalex.EvaluationException - occurred when evaluating
      com.ezylang.evalex.parser.ParseException - if the expression is invalid
    • evaluateSafe

      public static Optional<com.ezylang.evalex.data.EvaluationValue> evaluateSafe(String expression, com.ezylang.evalex.config.ExpressionConfiguration expressionConfiguration)
      Evaluate the expression
      Parameters:
      expression - the expression
      expressionConfiguration - the expression configuration
      Returns:
      the result
    • evaluateSafe

      public static Optional<com.ezylang.evalex.data.EvaluationValue> evaluateSafe(String expression, com.ezylang.evalex.config.ExpressionConfiguration expressionConfiguration, Map<String,Object> values)
      Evaluate the expression
      Parameters:
      expression - the expression
      expressionConfiguration - the expression configuration
      values - the values
      Returns:
      the result
    • evaluateSafe

      public static Optional<com.ezylang.evalex.data.EvaluationValue> evaluateSafe(String expression, Map<String,Object> values)
      Evaluate the expression
      Parameters:
      expression - the expression
      values - the values
      Returns:
      the result
    • evaluateSafe

      public static Optional<com.ezylang.evalex.data.EvaluationValue> evaluateSafe(String expression)
      Evaluate the expression
      Parameters:
      expression - the expression
      Returns:
      the result