Class ClosureTransformer<T>

    • Constructor Detail

      • ClosureTransformer

        public ClosureTransformer​(Closure<? super T> closure)
        Constructor that performs no validation. Use closureTransformer if you want that.
        Parameters:
        closure - the closure to call, not null
    • Method Detail

      • closureTransformer

        public static <T> Transformer<T,​T> closureTransformer​(Closure<? super T> closure)
        Factory method that performs validation.
        Type Parameters:
        T - the type of the object to transform
        Parameters:
        closure - the closure to call, not null
        Returns:
        the closure transformer
        Throws:
        NullPointerException - if the closure is null
      • transform

        public T transform​(T input)
        Transforms the input to result by executing a closure.
        Specified by:
        transform in interface Transformer<T,​T>
        Parameters:
        input - the input object to transform
        Returns:
        the transformed result
      • getClosure

        public Closure<? super T> getClosure()
        Gets the closure.
        Returns:
        the closure
        Since:
        3.1