S
- The evaluation context root object type.public class FunctionExpression<S>
extends java.lang.Object
implements org.springframework.expression.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(Function<S,?> function) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getExpressionString() |
java.lang.Object |
getValue() |
<T> T |
getValue(java.lang.Class<T> desiredResultType) |
java.lang.Object |
getValue(org.springframework.expression.EvaluationContext context) |
<T> T |
getValue(org.springframework.expression.EvaluationContext context,
java.lang.Class<T> desiredResultType) |
java.lang.Object |
getValue(org.springframework.expression.EvaluationContext context,
java.lang.Object rootObject) |
<T> T |
getValue(org.springframework.expression.EvaluationContext context,
java.lang.Object rootObject,
java.lang.Class<T> desiredResultType) |
java.lang.Object |
getValue(java.lang.Object rootObject) |
<T> T |
getValue(java.lang.Object rootObject,
java.lang.Class<T> desiredResultType) |
java.lang.Class<?> |
getValueType() |
java.lang.Class<?> |
getValueType(org.springframework.expression.EvaluationContext context) |
java.lang.Class<?> |
getValueType(org.springframework.expression.EvaluationContext context,
java.lang.Object rootObject) |
java.lang.Class<?> |
getValueType(java.lang.Object rootObject) |
org.springframework.core.convert.TypeDescriptor |
getValueTypeDescriptor() |
org.springframework.core.convert.TypeDescriptor |
getValueTypeDescriptor(org.springframework.expression.EvaluationContext context) |
org.springframework.core.convert.TypeDescriptor |
getValueTypeDescriptor(org.springframework.expression.EvaluationContext context,
java.lang.Object rootObject) |
org.springframework.core.convert.TypeDescriptor |
getValueTypeDescriptor(java.lang.Object rootObject) |
boolean |
isWritable(org.springframework.expression.EvaluationContext context) |
boolean |
isWritable(org.springframework.expression.EvaluationContext context,
java.lang.Object rootObject) |
boolean |
isWritable(java.lang.Object rootObject) |
void |
setValue(org.springframework.expression.EvaluationContext context,
java.lang.Object value) |
void |
setValue(org.springframework.expression.EvaluationContext context,
java.lang.Object rootObject,
java.lang.Object value) |
void |
setValue(java.lang.Object rootObject,
java.lang.Object value) |
public java.lang.Object getValue() throws org.springframework.expression.EvaluationException
getValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public java.lang.Object getValue(java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
getValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public <T> T getValue(java.lang.Class<T> desiredResultType) throws org.springframework.expression.EvaluationException
getValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public <T> T getValue(java.lang.Object rootObject, java.lang.Class<T> desiredResultType) throws org.springframework.expression.EvaluationException
getValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public java.lang.Object getValue(org.springframework.expression.EvaluationContext context) throws org.springframework.expression.EvaluationException
getValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public java.lang.Object getValue(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
getValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public <T> T getValue(org.springframework.expression.EvaluationContext context, java.lang.Class<T> desiredResultType) throws org.springframework.expression.EvaluationException
getValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public <T> T getValue(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject, java.lang.Class<T> desiredResultType) throws org.springframework.expression.EvaluationException
getValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public java.lang.Class<?> getValueType() throws org.springframework.expression.EvaluationException
getValueType
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public java.lang.Class<?> getValueType(java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
getValueType
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public java.lang.Class<?> getValueType(org.springframework.expression.EvaluationContext context) throws org.springframework.expression.EvaluationException
getValueType
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public java.lang.Class<?> getValueType(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
getValueType
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor() throws org.springframework.expression.EvaluationException
getValueTypeDescriptor
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor(java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
getValueTypeDescriptor
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor(org.springframework.expression.EvaluationContext context) throws org.springframework.expression.EvaluationException
getValueTypeDescriptor
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
getValueTypeDescriptor
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public void setValue(org.springframework.expression.EvaluationContext context, java.lang.Object value) throws org.springframework.expression.EvaluationException
setValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public void setValue(java.lang.Object rootObject, java.lang.Object value) throws org.springframework.expression.EvaluationException
setValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public void setValue(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject, java.lang.Object value) throws org.springframework.expression.EvaluationException
setValue
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public boolean isWritable(org.springframework.expression.EvaluationContext context) throws org.springframework.expression.EvaluationException
isWritable
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public boolean isWritable(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
isWritable
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public boolean isWritable(java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
isWritable
in interface org.springframework.expression.Expression
org.springframework.expression.EvaluationException
public java.lang.String getExpressionString()
getExpressionString
in interface org.springframework.expression.Expression