|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections.FactoryUtils
public class FactoryUtils
FactoryUtils provides reference implementations and utilities
for the Factory functor interface. The supplied factories are:
| Constructor Summary | |
|---|---|
FactoryUtils()
This class is not normally instantiated. |
|
| Method Summary | ||
|---|---|---|
static
|
constantFactory(T 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
|
instantiateFactory(Class<T> classToInstantiate)
Creates a Factory that can create objects of a specific type using a no-args constructor. |
|
static
|
instantiateFactory(Class<T> 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
|
prototypeFactory(T prototype)
Creates a Factory that will return a clone of the same prototype object each time the factory is used. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FactoryUtils()
| Method Detail |
|---|
public static Factory exceptionFactory()
ExceptionFactorypublic static Factory nullFactory()
ConstantFactorypublic static <T> Factory<T> constantFactory(T constantToReturn)
constantToReturn - the constant object to return each time in the factory
constant factory.ConstantFactorypublic static <T> Factory<T> prototypeFactory(T prototype)
prototype - the object to clone each time in the factory
prototype factory
IllegalArgumentException - if the prototype is null
IllegalArgumentException - if the prototype cannot be clonedPrototypeFactorypublic static <T> Factory<T> instantiateFactory(Class<T> classToInstantiate)
classToInstantiate - the Class to instantiate each time in the factory
reflection factory
IllegalArgumentException - if the classToInstantiate is nullInstantiateFactory
public static <T> Factory<T> instantiateFactory(Class<T> classToInstantiate,
Class[] paramTypes,
Object[] args)
classToInstantiate - the Class to instantiate each time in the factoryparamTypes - parameter types for the constructor, can be nullargs - the arguments to pass to the constructor, can be null
reflection factory
IllegalArgumentException - if the classToInstantiate is null
IllegalArgumentException - if the paramTypes and args don't match
IllegalArgumentException - if the constructor doesn't existInstantiateFactory
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||