S
- The evaluation context root object type.public class FunctionExpression<S> extends Object implements Expression
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
.
Constructor and Description |
---|
FunctionExpression(java.util.function.Function<S,?> function) |
public FunctionExpression(java.util.function.Function<S,?> function)
@Nullable public Object getValue() throws EvaluationException
getValue
in interface Expression
EvaluationException
@Nullable public Object getValue(@Nullable Object rootObject) throws EvaluationException
getValue
in interface Expression
EvaluationException
@Nullable public <T> T getValue(@Nullable Class<T> desiredResultType) throws EvaluationException
getValue
in interface Expression
EvaluationException
@Nullable public <T> T getValue(@Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException
getValue
in interface Expression
EvaluationException
@Nullable public Object getValue(EvaluationContext context) throws EvaluationException
getValue
in interface Expression
EvaluationException
@Nullable public Object getValue(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
getValue
in interface Expression
EvaluationException
@Nullable public <T> T getValue(EvaluationContext context, @Nullable Class<T> desiredResultType) throws EvaluationException
getValue
in interface Expression
EvaluationException
@Nullable public <T> T getValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException
getValue
in interface Expression
EvaluationException
public Class<?> getValueType() throws EvaluationException
getValueType
in interface Expression
EvaluationException
public Class<?> getValueType(@Nullable Object rootObject) throws EvaluationException
getValueType
in interface Expression
EvaluationException
public Class<?> getValueType(EvaluationContext context) throws EvaluationException
getValueType
in interface Expression
EvaluationException
public Class<?> getValueType(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
getValueType
in interface Expression
EvaluationException
public TypeDescriptor getValueTypeDescriptor() throws EvaluationException
getValueTypeDescriptor
in interface Expression
EvaluationException
public TypeDescriptor getValueTypeDescriptor(@Nullable Object rootObject) throws EvaluationException
getValueTypeDescriptor
in interface Expression
EvaluationException
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException
getValueTypeDescriptor
in interface Expression
EvaluationException
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
getValueTypeDescriptor
in interface Expression
EvaluationException
public void setValue(EvaluationContext context, @Nullable Object value) throws EvaluationException
setValue
in interface Expression
EvaluationException
public void setValue(@Nullable Object rootObject, @Nullable Object value) throws EvaluationException
setValue
in interface Expression
EvaluationException
public void setValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Object value) throws EvaluationException
setValue
in interface Expression
EvaluationException
public boolean isWritable(EvaluationContext context) throws EvaluationException
isWritable
in interface Expression
EvaluationException
public boolean isWritable(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
isWritable
in interface Expression
EvaluationException
public boolean isWritable(@Nullable Object rootObject) throws EvaluationException
isWritable
in interface Expression
EvaluationException
public final String getExpressionString()
getExpressionString
in interface Expression