1 16 package org.apache.commons.collections.functors; 17 18 import java.io.Serializable ; 19 20 import org.apache.commons.collections.Factory; 21 import org.apache.commons.collections.Transformer; 22 23 31 public class FactoryTransformer implements Transformer, Serializable { 32 33 34 static final long serialVersionUID = -6817674502475353160L; 35 36 37 private final Factory iFactory; 38 39 46 public static Transformer getInstance(Factory factory) { 47 if (factory == null) { 48 throw new IllegalArgumentException ("Factory must not be null"); 49 } 50 return new FactoryTransformer(factory); 51 } 52 53 59 public FactoryTransformer(Factory factory) { 60 super(); 61 iFactory = factory; 62 } 63 64 71 public Object transform(Object input) { 72 return iFactory.create(); 73 } 74 75 81 public Factory getFactory() { 82 return iFactory; 83 } 84 85 } 86 | Popular Tags |