| |
|
| java.lang.Object org.apache.commons.collections.FactoryUtils
FactoryUtils | public class FactoryUtils (Code) | | FactoryUtils provides reference implementations and utilities
for the Factory functor interface. The supplied factories are:
- Prototype - clones a specified object
- Reflection - creates objects using reflection
- Constant - always returns the same object
- Null - always returns null
- Exception - always throws an exception
All the supplied factories are Serializable.
since: Commons Collections 3.0 version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $ author: Stephen Colebourne |
Constructor Summary | |
public | FactoryUtils() This class is not normally instantiated. |
Method Summary | |
public static Factory | constantFactory(Object constantToReturn) Creates a Factory that will return the same object each time the factory
is used. | public static Factory | exceptionFactory() Gets a Factory that always throws an exception. | public static Factory | instantiateFactory(Class classToInstantiate) Creates a Factory that can create objects of a specific type using
a no-args constructor. | public static Factory | instantiateFactory(Class classToInstantiate, Class[] paramTypes, Object[] args) Creates a Factory that can create objects of a specific type using
the arguments specified to this method. | public static Factory | nullFactory() Gets a Factory that will return null each time the factory is used. | public static Factory | prototypeFactory(Object prototype) Creates a Factory that will return a clone of the same prototype object
each time the factory is used. |
FactoryUtils | public FactoryUtils()(Code) | | This class is not normally instantiated.
|
constantFactory | public static Factory constantFactory(Object constantToReturn)(Code) | | 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 Also: org.apache.commons.collections.functors.ConstantFactory Parameters: constantToReturn - the constant object to return each time in the factory the constant factory. |
prototypeFactory | public static Factory prototypeFactory(Object prototype)(Code) | | Creates a Factory that will return a clone of the same prototype object
each time the factory is used. The prototype will be cloned using one of these
techniques (in order):
- public clone method
- public copy constructor
- serialization clone
|
|
|
|