1 16 package org.apache.commons.collections.functors; 17 18 import java.io.Serializable ; 19 20 import org.apache.commons.collections.Closure; 21 import org.apache.commons.collections.Transformer; 22 23 32 public class ClosureTransformer implements Transformer, Serializable { 33 34 35 static final long serialVersionUID = 478466901448617286L; 36 37 38 private final Closure iClosure; 39 40 47 public static Transformer getInstance(Closure closure) { 48 if (closure == null) { 49 throw new IllegalArgumentException ("Closure must not be null"); 50 } 51 return new ClosureTransformer(closure); 52 } 53 54 60 public ClosureTransformer(Closure closure) { 61 super(); 62 iClosure = closure; 63 } 64 65 71 public Object transform(Object input) { 72 iClosure.execute(input); 73 return input; 74 } 75 76 82 public Closure getClosure() { 83 return iClosure; 84 } 85 86 } 87 | Popular Tags |