org.apache.commons.collections
public class FactoryUtils extends Object
FactoryUtils
provides reference implementations and utilities
for the Factory functor interface. The supplied factories are:
Since: Commons Collections 3.0
Version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
Constructor Summary | |
---|---|
FactoryUtils()
This class is not normally instantiated. |
Method Summary | |
---|---|
static Factory | constantFactory(Object constantToReturn)
Creates a Factory that will return the same object each time the factory
is used. |
static Factory | exceptionFactory()
Gets a Factory that always throws an exception.
|
static Factory | instantiateFactory(Class classToInstantiate)
Creates a Factory that can create objects of a specific type using
a no-args constructor.
|
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.
|
static Factory | nullFactory()
Gets a Factory that will return null each time the factory is used.
|
static Factory | prototypeFactory(Object prototype)
Creates a Factory that will return a clone of the same prototype object
each time the factory is used. |
Parameters: constantToReturn the constant object to return each time in the factory
Returns: the constant
factory.
Returns: the factory
Parameters: classToInstantiate the Class to instantiate each time in the factory
Returns: the reflection
factory
Throws: IllegalArgumentException if the classToInstantiate is null
Parameters: classToInstantiate the Class to instantiate each time in the factory paramTypes parameter types for the constructor, can be null args the arguments to pass to the constructor, can be null
Returns: the reflection
factory
Throws: IllegalArgumentException if the classToInstantiate is null IllegalArgumentException if the paramTypes and args don't match IllegalArgumentException if the constructor doesn't exist
Returns: the factory