/** * 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.collections.functors.ConstantFactory * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory constantFactory(Object constantToReturn) { return ConstantFactory.getInstance(constantToReturn); }
/** * Factory method that performs validation. * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory getInstance(Object constantToReturn) { if (constantToReturn == null) { return NULL_INSTANCE; } return new ConstantFactory(constantToReturn); }
/** * 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.collections.functors.ConstantFactory * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory constantFactory(Object constantToReturn) { return ConstantFactory.getInstance(constantToReturn); }
/** * Factory method that performs validation. * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory getInstance(Object constantToReturn) { if (constantToReturn == null) { return NULL_INSTANCE; } return new ConstantFactory(constantToReturn); }
public void testMapGet3() { HashMap base = new HashMap(); Map map = DefaultedMap.decorate(base, ConstantFactory.getInstance("NULL")); assertEquals(0, map.size()); assertEquals(0, base.size()); assertEquals(false, map.containsKey("NotInMap")); assertEquals("NULL", map.get("NotInMap")); map.put("Key", "Value"); assertEquals(1, map.size()); assertEquals(1, base.size()); assertEquals(true, map.containsKey("Key")); assertEquals("Value", map.get("Key")); assertEquals(false, map.containsKey("NotInMap")); assertEquals("NULL", map.get("NotInMap")); }
/** * Factory method that performs validation. * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory getInstance(Object constantToReturn) { if (constantToReturn == null) { return NULL_INSTANCE; } return new ConstantFactory(constantToReturn); }
/** * 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.collections.functors.ConstantFactory * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory constantFactory(Object constantToReturn) { return ConstantFactory.getInstance(constantToReturn); }
/** * Factory method that performs validation. * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory getInstance(Object constantToReturn) { if (constantToReturn == null) { return NULL_INSTANCE; } return new ConstantFactory(constantToReturn); }
/** * 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.collections.functors.ConstantFactory * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory constantFactory(Object constantToReturn) { return ConstantFactory.getInstance(constantToReturn); }
/** * Factory method that performs validation. * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory getInstance(Object constantToReturn) { if (constantToReturn == null) { return NULL_INSTANCE; } return new ConstantFactory(constantToReturn); }
/** * 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.collections.functors.ConstantFactory * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory constantFactory(Object constantToReturn) { return ConstantFactory.getInstance(constantToReturn); }
/** * Factory method that performs validation. * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory getInstance(Object constantToReturn) { if (constantToReturn == null) { return NULL_INSTANCE; } return new ConstantFactory(constantToReturn); }
/** * 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.collections.functors.ConstantFactory * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory constantFactory(Object constantToReturn) { return ConstantFactory.getInstance(constantToReturn); }
/** * Factory method that performs validation. * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory getInstance(Object constantToReturn) { if (constantToReturn == null) { return NULL_INSTANCE; } return new ConstantFactory(constantToReturn); }
/** * 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.collections.functors.ConstantFactory * * @param constantToReturn the constant object to return each time in the factory * @return the <code>constant</code> factory. */ public static Factory constantFactory(Object constantToReturn) { return ConstantFactory.getInstance(constantToReturn); }