1 16 package org.apache.commons.collections.functors; 17 18 import java.io.Serializable ; 19 import java.util.Map ; 20 21 import org.apache.commons.collections.Transformer; 22 23 32 public final class MapTransformer implements Transformer, Serializable { 33 34 35 static final long serialVersionUID = 862391807045468939L; 36 37 38 private final Map iMap; 39 40 48 public static Transformer getInstance(Map map) { 49 if (map == null) { 50 return ConstantTransformer.NULL_INSTANCE; 51 } 52 return new MapTransformer(map); 53 } 54 55 61 private MapTransformer(Map map) { 62 super(); 63 iMap = map; 64 } 65 66 72 public Object transform(Object input) { 73 return iMap.get(input); 74 } 75 76 82 public Map getMap() { 83 return iMap; 84 } 85 86 } 87 | Popular Tags |