Class 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
    • Constructor Detail

      • SwitchFunction

        public SwitchFunction()
    • Method Detail

      • evaluate

        public EvaluationValue evaluate​(Expression expression,
                                        Token functionToken,
                                        EvaluationValue... parameterValues)
                                 throws EvaluationException
        Description copied from interface: FunctionIfc
        Performs 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.