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
public abstract class AbstractSpringExpressionEvaluatorEx extends Object
A component that evaluates a Spring EL expression against a set of inputs and returns the result.- Since:
- 6.1.0
-
-
Field Summary
Fields Modifier and Type Field Description private ObjectcustomObjectA custom object to inject into the expression context.private booleanhideExceptionsWhether to raise runtime exceptions if expression fails.private org.slf4j.LoggerlogClass logger.private Class<?>outputTypeThe output type.private ObjectreturnOnErrorValue to return from predicate when an error occurs.private StringspringExpressionSpEL expression to evaluate.
-
Constructor Summary
Constructors Constructor Description AbstractSpringExpressionEvaluatorEx(String expression)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Objectevaluate(Object... input)Evaluate the Spring expression on the provided input.protected ObjectgetCustomObject()Get the custom (externally provided) object.protected Class<?>getOutputType()Get the output type to be enforced.protected ObjectgetReturnOnError()Get 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 Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
springExpression
@Nullable private String springExpression
SpEL expression to evaluate.
-
customObject
@Nullable private Object customObject
A custom object to inject into the expression context.
-
outputType
@Nullable private Class<?> outputType
The output type.
-
hideExceptions
private boolean hideExceptions
Whether to raise runtime exceptions if expression fails.
-
returnOnError
@Nullable private Object returnOnError
Value to return from predicate when an error occurs.
-
-
Constructor Detail
-
AbstractSpringExpressionEvaluatorEx
public AbstractSpringExpressionEvaluatorEx(@Nonnull @NotEmpty @ParameterName(name="expression") String expression)
Constructor.- Parameters:
expression- the expression to evaluate
-
-
Method Detail
-
getOutputType
@Nullable protected Class<?> getOutputType()
Get the output type to be enforced.- Returns:
- output type
-
setOutputType
protected void setOutputType(@Nullable Class<?> type)Set the output type to be enforced.- Parameters:
type- output type
-
getCustomObject
@Nullable protected Object getCustomObject()
Get the custom (externally provided) object.- Returns:
- the custom object
-
setCustomObject
public void setCustomObject(@Nullable Object object)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
@Nullable protected Object getReturnOnError()
Get value to return if an error occurs.- Returns:
- value to return
-
setReturnOnError
protected void setReturnOnError(@Nullable Object value)Set value to return if an error occurs.- Parameters:
value- value to return
-
evaluate
@Nullable protected Object evaluate(@Nullable Object... input)
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
-
-