Package me.hsgamer.hscore.expression
Class ExpressionUtils
java.lang.Object
me.hsgamer.hscore.expression.ExpressionUtils
The expression manager
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.ezylang.evalex.ExpressioncreateExpression(String expression) Create an expressionstatic com.ezylang.evalex.data.EvaluationValueEvaluate the expressionstatic com.ezylang.evalex.data.EvaluationValueEvaluate the expressionstatic Optional<com.ezylang.evalex.data.EvaluationValue>evaluateSafe(String expression) Evaluate the expressionstatic Optional<com.ezylang.evalex.data.EvaluationValue>evaluateSafe(String expression, Map<String, Object> values) Evaluate the expressionstatic com.ezylang.evalex.config.ExpressionConfigurationGet the expression configurationstatic voidregisterFunction(String name, com.ezylang.evalex.functions.FunctionIfc function) Register a functionstatic voidregisterOperator(String name, com.ezylang.evalex.operators.OperatorIfc operator) Register an operator
-
Method Details
-
registerFunction
Register a function- Parameters:
name- the name of the functionfunction- the function
-
registerOperator
Register an operator- Parameters:
name- the name of the operatoroperator- the operator
-
getExpressionConfiguration
public static com.ezylang.evalex.config.ExpressionConfiguration getExpressionConfiguration()Get the expression configuration- Returns:
- the expression configuration
-
createExpression
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 evaluatingcom.ezylang.evalex.parser.ParseException- if the expression is invalid
-
evaluateSafe
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.ParseExceptionEvaluate the expression- Parameters:
expression- the expressionvalues- the values- Returns:
- the result
- Throws:
com.ezylang.evalex.EvaluationException- occurred when evaluatingcom.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 expressionvalues- the values- Returns:
- the result
-