public final class ExpressionUtil
extends java.lang.Object
Expression.| Modifier and Type | Method and Description |
|---|---|
static Expression |
constantExpression(java.lang.Object value) |
static java.lang.String |
evaluateLeniently(Expression expression,
Mapping<java.lang.String,?> variables) |
static <T> T |
evaluateTo(Expression expression,
Mapping<java.lang.String,?> variables,
java.lang.Class<T> targetClass) |
static Expression |
expand(java.lang.String s,
Predicate<? super java.lang.String> isValidVariableName)
Turns the given string into an expression.
|
static Expression |
expand(java.lang.String s,
java.util.Set<java.lang.String> variableNames)
Turns the given string into an expression.
|
static Expression |
fromPredicate(Predicate<? super java.lang.String> predicate,
java.lang.String variableName) |
static Expression |
logicalAnd(Expression operand1,
Expression operand2) |
static Expression |
logicalOr(Expression operand1,
Expression operand2) |
static <T> Predicate<T> |
toPredicate(Expression expression,
java.lang.String parameterName) |
public static Expression constantExpression(@Nullable java.lang.Object value)
Expression that evaluates to a constant value.public static Expression expand(java.lang.String s, java.util.Set<java.lang.String> variableNames) throws ParseException
s - The string to expandvariableNames - All contained variable names can be used in the expressionParseExceptionpublic static Expression expand(java.lang.String s, Predicate<? super java.lang.String> isValidVariableName) throws ParseException
s - The string to expandisValidVariableName - Evalutaes to whether the subject is a valid variable nameParseExceptionpublic static java.lang.String evaluateLeniently(Expression expression, Mapping<java.lang.String,?> variables)
@Nullable public static <T> T evaluateTo(Expression expression, Mapping<java.lang.String,?> variables, java.lang.Class<T> targetClass) throws EvaluationException
EvaluationException - The expression evaluates to nullEvaluationException - A problem occurred during evaluation, e.g. a class could not be loaded, or a type
cast could not be performedpublic static <T> Predicate<T> toPredicate(Expression expression, java.lang.String parameterName)
parameterName - The name under which the predicate subject is accessible for the expressionPredicate which evaluates to the value of the given expressionpublic static Expression fromPredicate(Predicate<? super java.lang.String> predicate, java.lang.String variableName)
Expression which evaluates to the result of the given predicate, where the subject
to the predicate is the value of the named variable of the expressionpublic static Expression logicalAnd(Expression operand1, Expression operand2)
Expression which evaluates the operand1, and, if that is true the
operand2public static Expression logicalOr(Expression operand1, Expression operand2)
Expression which evaluates the operand1, and, if that is false the
operand2