Class FunctionExpression<S>
java.lang.Object
org.springframework.integration.expression.FunctionExpression<S>
- Type Parameters:
S
- The evaluation context root object type.
- All Implemented Interfaces:
Expression
An
Expression
that simply invokes Function.apply(Object)
on its
provided Function
.
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 FunctionExpression
can be specified instead of a
SpelExpression
as an alternative to evaluate the value from the Lambda, rather than runtime SpEL resolution.
The FunctionExpression
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 -
Method Summary
Modifier and TypeMethodDescriptionfinal String
@Nullable Object
getValue()
<T> @Nullable T
@Nullable Object
<T> @Nullable T
@Nullable Object
getValue
(EvaluationContext context) <T> @Nullable T
getValue
(EvaluationContext context, @Nullable Class<T> desiredResultType) @Nullable Object
getValue
(EvaluationContext context, @Nullable Object rootObject) <T> @Nullable T
getValue
(EvaluationContext context, @Nullable Object rootObject, @Nullable Class<T> desiredResultType) Class<?>
Class<?>
getValueType
(@Nullable Object rootObject) Class<?>
getValueType
(EvaluationContext context) Class<?>
getValueType
(EvaluationContext context, @Nullable Object rootObject) getValueTypeDescriptor
(@Nullable Object rootObject) getValueTypeDescriptor
(EvaluationContext context) getValueTypeDescriptor
(EvaluationContext context, @Nullable Object rootObject) boolean
isWritable
(@Nullable Object rootObject) boolean
isWritable
(EvaluationContext context) boolean
isWritable
(EvaluationContext context, @Nullable Object rootObject) void
void
setValue
(EvaluationContext context, @Nullable Object value) void
setValue
(EvaluationContext context, @Nullable Object rootObject, @Nullable Object value)
-
Constructor Details
-
FunctionExpression
-
-
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
public <T> @Nullable T getValue(@Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException - Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
- Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
public @Nullable Object getValue(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException - Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
public <T> @Nullable T getValue(EvaluationContext context, @Nullable Class<T> desiredResultType) throws EvaluationException - Specified by:
getValue
in interfaceExpression
- Throws:
EvaluationException
-
getValue
public <T> @Nullable T getValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Class<T> 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, @Nullable Object rootObject) throws EvaluationException - Specified by:
getValueType
in interfaceExpression
- Throws:
EvaluationException
-
getValueTypeDescriptor
- Specified by:
getValueTypeDescriptor
in interfaceExpression
- Throws:
EvaluationException
-
getValueTypeDescriptor
public TypeDescriptor getValueTypeDescriptor(@Nullable Object rootObject) throws EvaluationException - Specified by:
getValueTypeDescriptor
in interfaceExpression
- Throws:
EvaluationException
-
getValueTypeDescriptor
- Specified by:
getValueTypeDescriptor
in interfaceExpression
- Throws:
EvaluationException
-
getValueTypeDescriptor
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException - Specified by:
getValueTypeDescriptor
in interfaceExpression
- Throws:
EvaluationException
-
setValue
- Specified by:
setValue
in interfaceExpression
- Throws:
EvaluationException
-
setValue
public void setValue(@Nullable Object rootObject, @Nullable Object value) throws EvaluationException - Specified by:
setValue
in interfaceExpression
- Throws:
EvaluationException
-
setValue
public void setValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Object value) throws EvaluationException - Specified by:
setValue
in interfaceExpression
- Throws:
EvaluationException
-
isWritable
- Specified by:
isWritable
in interfaceExpression
- Throws:
EvaluationException
-
isWritable
public boolean isWritable(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException - Specified by:
isWritable
in interfaceExpression
- Throws:
EvaluationException
-
isWritable
- Specified by:
isWritable
in interfaceExpression
- Throws:
EvaluationException
-
getExpressionString
- Specified by:
getExpressionString
in interfaceExpression
-