Class ExpressionUtils

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

public final class ExpressionUtils extends Object
The expression manager
  • 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
    • getExpressionConfiguration

      public static com.ezylang.evalex.config.ExpressionConfiguration getExpressionConfiguration()
      Get the expression configuration
      Returns:
      the expression configuration
    • 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) 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)
      Evaluate the expression
      Parameters:
      expression - the expression
      Returns:
      the result
    • 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
    • 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