Class ChainedTransformer<T>

  • All Implemented Interfaces:
    java.io.Serializable, Transformer<T,​T>

    public class ChainedTransformer<T>
    extends java.lang.Object
    implements Transformer<T,​T>, java.io.Serializable
    Transformer implementation that chains the specified transformers together.

    The input object is passed to the first transformer. The transformed result is passed to the second transformer and so on.

    Since:
    3.0
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ChainedTransformer​(Transformer<? super T,​? extends T>... transformers)
      Constructor that performs no validation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> Transformer<T,​T> chainedTransformer​(java.util.Collection<? extends Transformer<? super T,​? extends T>> transformers)
      Create a new Transformer that calls each transformer in turn, passing the result into the next transformer.
      static <T> Transformer<T,​T> chainedTransformer​(Transformer<? super T,​? extends T>... transformers)
      Factory method that performs validation and copies the parameter array.
      Transformer<? super T,​? extends T>[] getTransformers()
      Gets the transformers.
      T transform​(T object)
      Transforms the input to result via each decorated transformer
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ChainedTransformer

        public ChainedTransformer​(Transformer<? super T,​? extends T>... transformers)
        Constructor that performs no validation. Use chainedTransformer if you want that.
        Parameters:
        transformers - the transformers to chain, copied, no nulls
    • Method Detail

      • chainedTransformer

        public static <T> Transformer<T,​T> chainedTransformer​(Transformer<? super T,​? extends T>... transformers)
        Factory method that performs validation and copies the parameter array.
        Type Parameters:
        T - the object type
        Parameters:
        transformers - the transformers to chain, copied, no nulls
        Returns:
        the chained transformer
        Throws:
        java.lang.NullPointerException - if the transformers array is null
        java.lang.NullPointerException - if any transformer in the array is null
      • chainedTransformer

        public static <T> Transformer<T,​T> chainedTransformer​(java.util.Collection<? extends Transformer<? super T,​? extends T>> transformers)
        Create a new Transformer that calls each transformer in turn, passing the result into the next transformer. The ordering is that of the iterator() method on the collection.
        Type Parameters:
        T - the object type
        Parameters:
        transformers - a collection of transformers to chain
        Returns:
        the chained transformer
        Throws:
        java.lang.NullPointerException - if the transformers collection is null
        java.lang.NullPointerException - if any transformer in the collection is null
      • transform

        public T transform​(T object)
        Transforms the input to result via each decorated transformer
        Specified by:
        transform in interface Transformer<T,​T>
        Parameters:
        object - the input object passed to the first transformer
        Returns:
        the transformed result
      • getTransformers

        public Transformer<? super T,​? extends T>[] getTransformers()
        Gets the transformers.
        Returns:
        a copy of the transformers
        Since:
        3.1