Class ChainedClosure<E>

  • All Implemented Interfaces:
    java.io.Serializable, Closure<E>

    public class ChainedClosure<E>
    extends java.lang.Object
    implements Closure<E>, java.io.Serializable
    Closure implementation that chains the specified closures together.
    Since:
    3.0
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Closure<? super E>[] iClosures
      The closures to call in turn
      private static long serialVersionUID
      Serial version UID
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ChainedClosure​(boolean clone, Closure<? super E>... closures)
      Hidden constructor for the use by the static factory methods.
        ChainedClosure​(Closure<? super E>... closures)
      Constructor that performs no validation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <E> Closure<E> chainedClosure​(java.util.Collection<? extends Closure<? super E>> closures)
      Create a new Closure that calls each closure in turn, passing the result into the next closure.
      static <E> Closure<E> chainedClosure​(Closure<? super E>... closures)
      Factory method that performs validation and copies the parameter array.
      void execute​(E input)
      Execute a list of closures.
      Closure<? super E>[] getClosures()
      Gets the closures.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Serial version UID
        See Also:
        Constant Field Values
      • iClosures

        private final Closure<? super E>[] iClosures
        The closures to call in turn
    • Constructor Detail

      • ChainedClosure

        private ChainedClosure​(boolean clone,
                               Closure<? super E>... closures)
        Hidden constructor for the use by the static factory methods.
        Parameters:
        clone - if true the input argument will be cloned
        closures - the closures to chain, no nulls
      • ChainedClosure

        public ChainedClosure​(Closure<? super E>... closures)
        Constructor that performs no validation. Use chainedClosure if you want that.
        Parameters:
        closures - the closures to chain, copied, no nulls
    • Method Detail

      • chainedClosure

        public static <E> Closure<E> chainedClosure​(Closure<? super E>... closures)
        Factory method that performs validation and copies the parameter array.
        Type Parameters:
        E - the type that the closure acts on
        Parameters:
        closures - the closures to chain, copied, no nulls
        Returns:
        the chained closure
        Throws:
        java.lang.NullPointerException - if the closures array is null
        java.lang.NullPointerException - if any closure in the array is null
      • chainedClosure

        public static <E> Closure<E> chainedClosure​(java.util.Collection<? extends Closure<? super E>> closures)
        Create a new Closure that calls each closure in turn, passing the result into the next closure. The ordering is that of the iterator() method on the collection.
        Type Parameters:
        E - the type that the closure acts on
        Parameters:
        closures - a collection of closures to chain
        Returns:
        the chained closure
        Throws:
        java.lang.NullPointerException - if the closures collection is null
        java.lang.NullPointerException - if any closure in the collection is null
      • execute

        public void execute​(E input)
        Execute a list of closures.
        Specified by:
        execute in interface Closure<E>
        Parameters:
        input - the input object passed to each closure
      • getClosures

        public Closure<? super E>[] getClosures()
        Gets the closures.
        Returns:
        a copy of the closures
        Since:
        3.1