Package net.shibboleth.shared.spring.expression

# Class AbstractSpringExpressionEvaluator

java.lang.Object
net.shibboleth.shared.spring.expression.AbstractSpringExpressionEvaluator

Direct Known Subclasses:
  `SpringExpressionBiConsumer`, `SpringExpressionBiFunction`, `SpringExpressionBiPredicate`, `SpringExpressionConsumer`, `SpringExpressionFunction`, `SpringExpressionPredicate`

public abstract class AbstractSpringExpressionEvaluator 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 Object`
`customObject`
A custom object to inject into the expression context.
`private boolean`
`hideExceptions`
Whether to raise runtime exceptions if expression fails.
`private final org.slf4j.Logger`
`log`
Class logger.
`private Class<?>`
`outputType`
The output type.
`private Object`
`returnOnError`
Value to return from predicate when an error occurs.
`private final String`
`springExpression`
SpEL expression to evaluate.

## Constructor Summary

Constructors
Constructor
Description
`AbstractSpringExpressionEvaluator(String expression)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected Object`
`evaluate(Object... input)`
Evaluate the Spring expression on the provided input.
`protected Object`
`getCustomObject()`
Get the custom (externally provided) object.
`protected Class<?>`
`getOutputType()`
Get the output type to be enforced.
`protected Object`
`getReturnOnError()`
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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### springExpression

@Nonnull private final 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 Details

### AbstractSpringExpressionEvaluator

public AbstractSpringExpressionEvaluator(@Nonnull @NotEmpty @ParameterName(name="expression") String expression)
Constructor.

Parameters:
  `expression` - the expression to evaluate

## Method Details

### 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 context
  `input` - the inputs