Class IteratorClosureAdapter<T>

java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.lang.Closure
org.codehaus.groovy.runtime.IteratorClosureAdapter<T>
All Implemented Interfaces:
GroovyCallable, GroovyObject, Serializable, Cloneable, Runnable, Callable

public class IteratorClosureAdapter<T> extends Closure
A closure which stores calls in a List so that method calls can be iterated over in a 'yield' style way
See Also:
  • Constructor Details

    • IteratorClosureAdapter

      public IteratorClosureAdapter(Object delegate)
      Creates an adapter whose owner is delegate. Calls are collected in a list that starts empty.
      Parameters:
      delegate - closure owner
  • Method Details

    • getMetaClass

      public MetaClass getMetaClass()
      Description copied from class: GroovyObjectSupport
      Returns the metaclass for a given class.
      Specified by:
      getMetaClass in interface GroovyObject
      Overrides:
      getMetaClass in class GroovyObjectSupport
      Returns:
      the metaClass of this instance
    • setMetaClass

      public void setMetaClass(MetaClass metaClass)
      Description copied from class: GroovyObjectSupport
      Allows the MetaClass to be replaced with a derived implementation.
      Specified by:
      setMetaClass in interface GroovyObject
      Overrides:
      setMetaClass in class Closure
      Parameters:
      metaClass - the new metaclass
    • asList

      public List<T> asList()
      Returns the values passed to doCall(T), in call order. Later calls append to the same list.
      Returns:
      the accumulated values
    • doCall

      protected Object doCall(T argument)
      Appends argument to the list returned by asList().
      Parameters:
      argument - value yielded by one call
      Returns:
      null