/** * Gets a Factory that will return null each time the factory is used. * This could be useful during testing as a placeholder. * * @see org.apache.commons.collections4.functors.ConstantFactory * @param <T> the "type" of null object the factory should return. * @return the factory */ public static <T> Factory<T> nullFactory() { return ConstantFactory.<T>constantFactory(null); }
/** * Creates a Factory that will return the same object each time the factory * is used. No check is made that the object is immutable. In general, only * immutable objects should use the constant factory. Mutable objects should * use the prototype factory. * * @see org.apache.commons.collections4.functors.ConstantFactory * * @param <T> the type that the factory creates * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static <T> Factory<T> constantFactory(final T constantToReturn) { return ConstantFactory.constantFactory(constantToReturn); }
public static <T> Factory<T> prototypeFactory(final T prototype) { if (prototype == null) { return ConstantFactory.<T>constantFactory(null);