Package net.shibboleth.ext.spring.util
Class AbstractSpringExpressionEvaluatorEx
java.lang.Object
net.shibboleth.ext.spring.util.AbstractSpringExpressionEvaluatorEx
- 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 Object
A custom object to inject into the expression context.private boolean
Whether to raise runtime exceptions if expression fails.private final org.slf4j.Logger
Class logger.private Class<?>
The output type.private Object
Value to return from predicate when an error occurs.private String
SpEL expression to evaluate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
Evaluate the Spring expression on the provided input.protected Object
Get the custom (externally provided) object.protected Class<?>
Get the output type to be enforced.protected Object
Get value to return if an error occurs.protected abstract void
prepareContext
(EvaluationContext context, Object... input) Pre-process the script context before execution.void
setCustomObject
(Object object) Set a custom (externally provided) object.void
setHideExceptions
(boolean flag) Set whether to hide exceptions in expression execution (default is false).protected void
setOutputType
(Class<?> type) Set the output type to be enforced.protected void
setReturnOnError
(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
-
AbstractSpringExpressionEvaluatorEx
public AbstractSpringExpressionEvaluatorEx(@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
-