Class SwitchFunction
- java.lang.Object
-
- com.ezylang.evalex.functions.AbstractFunction
-
- com.ezylang.evalex.functions.basic.SwitchFunction
-
- All Implemented Interfaces:
FunctionIfc
@FunctionParameter(name="expression") @FunctionParameter(name="value1") @FunctionParameter(name="result1",isLazy=true) @FunctionParameter(name="additionalValues",isLazy=true,isVarArg=true) public class SwitchFunction extends AbstractFunction
A function that evaluates one value (or expression) against a list of values, and returns the result corresponding to the first matching value. If there is no match, an optional default value may be returned.Syntax:
SWITCH(expression, value1, result1, [value, result, ...], [default])Examples:
1. The following function will return either "Sunday", "Monday", or "Tuesday", depending on the result of the variable
weekday. Since no default value was specified, the function will return a null value if there is no match:SWITCH(weekday, 1, "Sunday", 2, "Monday", 3, "Tuesday")2. The following function will return either "Sunday", "Monday", "Tuesday", or "No match", depending on the result of the variable
weekday:SWITCH(weekday, 1, "Sunday", 2, "Monday", 3, "Tuesday", "No match")- Author:
- oswaldo.bapvic.jr
-
-
Field Summary
-
Fields inherited from class com.ezylang.evalex.functions.AbstractFunction
MINUS_ONE
-
-
Constructor Summary
Constructors Constructor Description SwitchFunction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EvaluationValueevaluate(Expression expression, Token functionToken, EvaluationValue... parameterValues)Performs the function logic and returns an evaluation result.-
Methods inherited from class com.ezylang.evalex.functions.AbstractFunction
getFunctionParameterDefinitions, hasVarArgs, validatePreEvaluation
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ezylang.evalex.functions.FunctionIfc
getCountOfNonVarArgParameters, isParameterLazy
-
-
-
-
Method Detail
-
evaluate
public EvaluationValue evaluate(Expression expression, Token functionToken, EvaluationValue... parameterValues) throws EvaluationException
Description copied from interface:FunctionIfcPerforms the function logic and returns an evaluation result.- Parameters:
expression- The expression, where this function is executed. Can be used to access the expression configuration.functionToken- The function token from the parsed expression.parameterValues- The parameter values.- Returns:
- The evaluation result in form of a
EvaluationValue. - Throws:
EvaluationException- In case there were problems during evaluation.
-
-