Class SupplierExpression<T>

java.lang.Object
org.springframework.integration.expression.SupplierExpression<T>
Type Parameters:
T - The type the Supplier will return.
All Implemented Interfaces:
org.springframework.expression.Expression

public class SupplierExpression<T>
extends java.lang.Object
implements org.springframework.expression.Expression
An 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.

Since:
5.0
  • Constructor Summary

    Constructors 
    Constructor Description
    SupplierExpression​(java.util.function.Supplier<T> supplier)  
  • Method Summary

    Modifier and Type Method Description
    java.lang.String getExpressionString()  
    java.lang.Object getValue()  
    <C> C getValue​(java.lang.Class<C> desiredResultType)  
    java.lang.Object getValue​(java.lang.Object rootObject)  
    <C> C getValue​(java.lang.Object rootObject, java.lang.Class<C> desiredResultType)  
    java.lang.Object getValue​(org.springframework.expression.EvaluationContext context)  
    <C> C getValue​(org.springframework.expression.EvaluationContext context, java.lang.Class<C> desiredResultType)  
    java.lang.Object getValue​(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject)  
    <C> C getValue​(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject, java.lang.Class<C> desiredResultType)  
    java.lang.Class<?> getValueType()  
    java.lang.Class<?> getValueType​(java.lang.Object rootObject)  
    java.lang.Class<?> getValueType​(org.springframework.expression.EvaluationContext context)  
    java.lang.Class<?> getValueType​(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject)  
    org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor()  
    org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor​(java.lang.Object rootObject)  
    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)  
    boolean isWritable​(java.lang.Object rootObject)  
    boolean isWritable​(org.springframework.expression.EvaluationContext context)  
    boolean isWritable​(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject)  
    void setValue​(java.lang.Object rootObject, java.lang.Object value)  
    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)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getValue

      public java.lang.Object getValue() throws org.springframework.expression.EvaluationException
      Specified by:
      getValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValue

      public java.lang.Object getValue​(java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
      Specified by:
      getValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValue

      public <C> C getValue​(java.lang.Class<C> desiredResultType) throws org.springframework.expression.EvaluationException
      Specified by:
      getValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValue

      public <C> C getValue​(java.lang.Object rootObject, java.lang.Class<C> desiredResultType) throws org.springframework.expression.EvaluationException
      Specified by:
      getValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValue

      public java.lang.Object getValue​(org.springframework.expression.EvaluationContext context) throws org.springframework.expression.EvaluationException
      Specified by:
      getValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValue

      public java.lang.Object getValue​(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
      Specified by:
      getValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValue

      public <C> C getValue​(org.springframework.expression.EvaluationContext context, java.lang.Class<C> desiredResultType) throws org.springframework.expression.EvaluationException
      Specified by:
      getValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValue

      public <C> C getValue​(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject, java.lang.Class<C> desiredResultType) throws org.springframework.expression.EvaluationException
      Specified by:
      getValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValueType

      public java.lang.Class<?> getValueType() throws org.springframework.expression.EvaluationException
      Specified by:
      getValueType in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValueType

      public java.lang.Class<?> getValueType​(java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
      Specified by:
      getValueType in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValueType

      public java.lang.Class<?> getValueType​(org.springframework.expression.EvaluationContext context) throws org.springframework.expression.EvaluationException
      Specified by:
      getValueType in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValueType

      public java.lang.Class<?> getValueType​(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
      Specified by:
      getValueType in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValueTypeDescriptor

      public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor() throws org.springframework.expression.EvaluationException
      Specified by:
      getValueTypeDescriptor in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValueTypeDescriptor

      public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor​(java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
      Specified by:
      getValueTypeDescriptor in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValueTypeDescriptor

      public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor​(org.springframework.expression.EvaluationContext context) throws org.springframework.expression.EvaluationException
      Specified by:
      getValueTypeDescriptor in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getValueTypeDescriptor

      public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor​(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
      Specified by:
      getValueTypeDescriptor in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • setValue

      public void setValue​(org.springframework.expression.EvaluationContext context, java.lang.Object value) throws org.springframework.expression.EvaluationException
      Specified by:
      setValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • setValue

      public void setValue​(java.lang.Object rootObject, java.lang.Object value) throws org.springframework.expression.EvaluationException
      Specified by:
      setValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • setValue

      public void setValue​(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject, java.lang.Object value) throws org.springframework.expression.EvaluationException
      Specified by:
      setValue in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • isWritable

      public boolean isWritable​(org.springframework.expression.EvaluationContext context) throws org.springframework.expression.EvaluationException
      Specified by:
      isWritable in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • isWritable

      public boolean isWritable​(org.springframework.expression.EvaluationContext context, java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
      Specified by:
      isWritable in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • isWritable

      public boolean isWritable​(java.lang.Object rootObject) throws org.springframework.expression.EvaluationException
      Specified by:
      isWritable in interface org.springframework.expression.Expression
      Throws:
      org.springframework.expression.EvaluationException
    • getExpressionString

      public final java.lang.String getExpressionString()
      Specified by:
      getExpressionString in interface org.springframework.expression.Expression