Class SupplierExpression<T>
java.lang.Object
org.springframework.integration.expression.SupplierExpression<T>
- Type Parameters:
T
- The type the Supplier will return.
- All Implemented Interfaces:
Expression
public class SupplierExpression<T> extends Object implements Expression
An
Expression
that simply invokes Supplier.get()
on its
provided Supplier
.
This is a powerful alternative to the SpEL, when Java 8 and its Lambda support is in use.
If the target component has support for an Expression
property,
a SupplierExpression
can be specified instead of a
SpelExpression
as an alternative to evaluate the value from the Lambda, rather than runtime SpEL resolution.
The SupplierExpression
is 'read-only', hence only getValue()
operations
are allowed.
Any setValue(org.springframework.expression.EvaluationContext, java.lang.Object)
operations and getValueType()
related operations
throw EvaluationException
.
- Since:
- 5.0
- Author:
- Artem Bilan, Gary Russell
-
Constructor Summary
Constructors Constructor Description SupplierExpression(Supplier<T> supplier)
-
Method Summary
-
Constructor Details
-
Method Details
-
getValue
- Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
- Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
- Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
- Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
- Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
- Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
public <C> C getValue(EvaluationContext context, Class<C> desiredResultType) throws EvaluationException- Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
public <C> C getValue(EvaluationContext context, Object rootObject, Class<C> desiredResultType) throws EvaluationException- Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValueType
- Specified by:
getValueType
in interfaceExpression
- Throws:
EvaluationException
-
getValueType
- Specified by:
getValueType
in interfaceExpression
- Throws:
EvaluationException
-
getValueType
- Specified by:
getValueType
in interfaceExpression
- Throws:
EvaluationException
-
getValueType
public Class<?> getValueType(EvaluationContext context, Object rootObject) throws EvaluationException- Specified by:
getValueType
in interfaceExpression
- Throws:
EvaluationException
-
getValueTypeDescriptor
- Specified by:
getValueTypeDescriptor
in interfaceExpression
- Throws:
EvaluationException
-
getValueTypeDescriptor
- Specified by:
getValueTypeDescriptor
in interfaceExpression
- Throws:
EvaluationException
-
getValueTypeDescriptor
- Specified by:
getValueTypeDescriptor
in interfaceExpression
- Throws:
EvaluationException
-
getValueTypeDescriptor
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException- Specified by:
getValueTypeDescriptor
in interfaceExpression
- Throws:
EvaluationException
-
setValue
- Specified by:
setValue
in interfaceExpression
- Throws:
EvaluationException
-
setValue
- Specified by:
setValue
in interfaceExpression
- Throws:
EvaluationException
-
setValue
public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException- Specified by:
setValue
in interfaceExpression
- Throws:
EvaluationException
-
isWritable
- Specified by:
isWritable
in interfaceExpression
- Throws:
EvaluationException
-
isWritable
- Specified by:
isWritable
in interfaceExpression
- Throws:
EvaluationException
-
isWritable
- Specified by:
isWritable
in interfaceExpression
- Throws:
EvaluationException
-
getExpressionString
- Specified by:
getExpressionString
in interfaceExpression
-