Class SpelAttributeValueMutator

    • Field Detail

      • logger

        protected final Logger logger
        Logger for this class.
      • attribute

        private final Attribute attribute
        Attribute containing the SPEL expression.
      • expression

        private final org.springframework.expression.Expression expression
        SPEL expression to access values.
      • evaluationContext

        private final org.springframework.expression.EvaluationContext evaluationContext
        Evaluation context.
      • transcoder

        private final ValueTranscoder transcoder
        Custom transcoder for this attribute.
    • Constructor Detail

      • SpelAttributeValueMutator

        public SpelAttributeValueMutator​(Attribute attr,
                                         org.springframework.expression.EvaluationContext context)
        Creates a new spel attribute value mutator.
        Parameters:
        attr - containing the SPEL configuration
        context - containing the values
    • Method Detail

      • getValues

        protected <T> Collection<T> getValues​(Object object,
                                              Class<T> type)
        Uses the configured expression and evaluation context to retrieve values from the supplied object. Values are the placed in a collection and returned.
        Type Parameters:
        T - either String or byte[]
        Parameters:
        object - to get values from
        type - of objects to place in the collection
        Returns:
        values in the supplied object
      • convertValue

        protected <T> T convertValue​(Object value,
                                     Class<?> sourceType,
                                     Class<T> targetType)
        Converts the supplied value to the target type. If a custom transcoder has been configured it is used. Otherwise, the type converter from the evaluation context is used.
        Type Parameters:
        T - either String or byte[]
        Parameters:
        value - to convert
        sourceType - to convert from
        targetType - to convert to
        Returns:
        converted value
      • setValues

        protected <T> void setValues​(Object object,
                                     Collection<T> values,
                                     Class<T> type)
        Uses the configured expression and evaluation context to set values on the supplied object. If a custom transcoder has been configured it is executed on the values before they are passed to the expression.
        Type Parameters:
        T - either String or byte[]
        Parameters:
        object - to set values on
        values - to set
        type - of objects in the collection
      • createCollection

        protected static <T> Collection<T> createCollection​(Class<?> type,
                                                            int size)
        Creates the best fit collection for the supplied type.
        Type Parameters:
        T - collection type
        Parameters:
        type - of collection to create
        size - of the collection
        Returns:
        collection