1 16 package org.apache.commons.collections.functors; 17 18 import java.io.Serializable ; 19 20 import org.apache.commons.collections.Factory; 21 22 34 public class ConstantFactory implements Factory, Serializable { 35 36 37 static final long serialVersionUID = -3520677225766901240L; 38 39 40 public static final Factory NULL_INSTANCE = new ConstantFactory(null); 41 42 43 private final Object iConstant; 44 45 51 public static Factory getInstance(Object constantToReturn) { 52 if (constantToReturn == null) { 53 return NULL_INSTANCE; 54 } 55 return new ConstantFactory(constantToReturn); 56 } 57 58 64 public ConstantFactory(Object constantToReturn) { 65 super(); 66 iConstant = constantToReturn; 67 } 68 69 74 public Object create() { 75 return iConstant; 76 } 77 78 84 public Object getConstant() { 85 return iConstant; 86 } 87 88 } 89 | Popular Tags |