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)
public Object getValue() throws EvaluationException
getValue
in interface Expression
EvaluationException
public Object getValue(Object rootObject) throws EvaluationException
getValue
in interface Expression
EvaluationException
public <T> T getValue(Class<T> desiredResultType) throws EvaluationException
getValue
in interface Expression
EvaluationException
public <T> T getValue(Object rootObject, Class<T> desiredResultType) throws EvaluationException
getValue
in interface Expression
EvaluationException
public Object getValue(EvaluationContext context) throws EvaluationException
getValue
in interface Expression
EvaluationException
public Object getValue(EvaluationContext context, Object rootObject) throws EvaluationException
getValue
in interface Expression
EvaluationException
public <T> T getValue(EvaluationContext context, Class<T> desiredResultType) throws EvaluationException
getValue
in interface Expression
EvaluationException
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType) throws EvaluationException
getValue
in interface Expression
EvaluationException
public Class<?> getValueType() throws EvaluationException
getValueType
in interface Expression
EvaluationException
public Class<?> getValueType(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, Object rootObject) throws EvaluationException
getValueType
in interface Expression
EvaluationException
public TypeDescriptor getValueTypeDescriptor() throws EvaluationException
getValueTypeDescriptor
in interface Expression
EvaluationException
public TypeDescriptor getValueTypeDescriptor(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, Object rootObject) throws EvaluationException
getValueTypeDescriptor
in interface Expression
EvaluationException
public void setValue(EvaluationContext context, Object value) throws EvaluationException
setValue
in interface Expression
EvaluationException
public void setValue(Object rootObject, Object value) throws EvaluationException
setValue
in interface Expression
EvaluationException
public void setValue(EvaluationContext context, Object rootObject, 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, Object rootObject) throws EvaluationException
isWritable
in interface Expression
EvaluationException
public boolean isWritable(Object rootObject) throws EvaluationException
isWritable
in interface Expression
EvaluationException
public String getExpressionString()
getExpressionString
in interface Expression