Class ConditionalFunctions.Switch
java.lang.Object
org.apache.juneau.commons.svl.TypedFunction
org.apache.juneau.commons.svl.functions.ConditionalFunctions.Switch
- All Implemented Interfaces:
VarFunction
- Enclosing class:
- ConditionalFunctions
#{switch(value, case1, val1, case2, val2, ..., default)} — replacement for the
legacy $SW{...}.
Compares value against each caseN glob pattern and returns the
matching valN for the first match. caseN patterns may contain *
(any sequence of characters) and ? (any single character) wildcards — same
semantics as the legacy SwitchVar. Plain literals (no wildcards) match by
full-string equality.
The last unmatched arg is the default; if the arg count is even (no trailing default), an empty string is returned for unmatched values.
Examples:
#{switch(${os}, *win*, Windows, *nix*, Linux, *)}— glob-routes by substring.#{switch(${env}, prod, A, dev, B, default)}— exact equality, three branches.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.juneau.commons.svl.TypedFunction
invoke, maxArity, minArity
-
Constructor Details
-
Switch
public Switch()
-
-
Method Details
-
name
Description copied from interface:VarFunctionThe function's invocation name as it appears between#{}and the opening parenthesis in the template. Must consist of ASCII letters, digits, and underscores; must begin with a letter.- Returns:
- The invocation name. Never
nullor empty.
-
invoke
-