1 package org.codehaus.groovy.runtime; 2 3 import groovy.lang.Closure; 4 import groovy.lang.MetaClass; 5 6 import java.util.ArrayList ; 7 import java.util.List ; 8 9 16 public class IteratorClosureAdapter extends Closure { 17 18 private List list = new ArrayList (); 19 private MetaClass metaClass = InvokerHelper.getMetaClass(this); 20 21 public IteratorClosureAdapter(Object delegate) { 22 super(delegate); 23 } 24 25 public MetaClass getMetaClass() { 26 return metaClass; 27 } 28 29 public void setMetaClass(MetaClass metaClass) { 30 this.metaClass = metaClass; 31 } 32 33 public List asList() { 34 return list; 35 } 36 37 protected Object doCall(Object argument) { 38 list.add(argument); 39 return null; 40 } 41 } 42 | Popular Tags |