T
- The type the Supplier will return.public class SupplierExpression<T> extends Object implements Expression
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
.
Constructor and Description |
---|
SupplierExpression(java.util.function.Supplier<T> supplier) |
public SupplierExpression(java.util.function.Supplier<T> supplier)
public Object getValue() throws EvaluationException
getValue
in interface Expression
EvaluationException
public Object getValue(Object rootObject) throws EvaluationException
getValue
in interface Expression
EvaluationException
public <C> C getValue(Class<C> desiredResultType) throws EvaluationException
getValue
in interface Expression
EvaluationException
public <C> C getValue(Object rootObject, Class<C> 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 <C> C getValue(EvaluationContext context, Class<C> desiredResultType) throws EvaluationException
getValue
in interface Expression
EvaluationException
public <C> C getValue(EvaluationContext context, Object rootObject, Class<C> 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 final String getExpressionString()
getExpressionString
in interface Expression