Class AbstractSpringExpressionEvaluator
java.lang.Object
net.shibboleth.shared.spring.expression.AbstractSpringExpressionEvaluator
- Direct Known Subclasses:
SpringExpressionBiConsumer,SpringExpressionBiFunction,SpringExpressionBiPredicate,SpringExpressionConsumer,SpringExpressionFunction,SpringExpressionPredicate
A component that evaluates a Spring EL expression against a set of inputs
and returns the result.
- Since:
- 6.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ObjectA custom object to inject into the expression context.private booleanWhether to raise runtime exceptions if expression fails.private final org.slf4j.LoggerClass logger.private Class<?>The output type.private ObjectValue to return from predicate when an error occurs.private final StringSpEL expression to evaluate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectEvaluate the Spring expression on the provided input.protected ObjectGet the custom (externally provided) object.protected Class<?>Get the output type to be enforced.protected ObjectGet value to return if an error occurs.protected abstract voidprepareContext(EvaluationContext context, Object... input) Pre-process the script context before execution.voidsetCustomObject(Object object) Set a custom (externally provided) object.voidsetHideExceptions(boolean flag) Set whether to hide exceptions in expression execution (default is false).protected voidsetOutputType(Class<?> type) Set the output type to be enforced.protected voidsetReturnOnError(Object value) Set value to return if an error occurs.
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
springExpression
SpEL expression to evaluate. -
customObject
A custom object to inject into the expression context. -
outputType
The output type. -
hideExceptions
private boolean hideExceptionsWhether to raise runtime exceptions if expression fails. -
returnOnError
Value to return from predicate when an error occurs.
-
-
Constructor Details
-
AbstractSpringExpressionEvaluator
public AbstractSpringExpressionEvaluator(@Nonnull @NotEmpty @ParameterName(name="expression") String expression) Constructor.- Parameters:
expression- the expression to evaluate
-
-
Method Details
-
getOutputType
Get the output type to be enforced.- Returns:
- output type
-
setOutputType
Set the output type to be enforced.- Parameters:
type- output type
-
getCustomObject
Get the custom (externally provided) object.- Returns:
- the custom object
-
setCustomObject
Set a custom (externally provided) object.- Parameters:
object- the custom object
-
setHideExceptions
public void setHideExceptions(boolean flag) Set whether to hide exceptions in expression execution (default is false).- Parameters:
flag- flag to set
-
getReturnOnError
Get value to return if an error occurs.- Returns:
- value to return
-
setReturnOnError
Set value to return if an error occurs.- Parameters:
value- value to return
-
evaluate
Evaluate the Spring expression on the provided input.- Parameters:
input- input arguments- Returns:
- result of applying the expression to the provided inputs
-
prepareContext
protected abstract void prepareContext(@Nonnull EvaluationContext context, @Nullable Object... input) Pre-process the script context before execution.- Parameters:
context- the expression contextinput- the inputs
-