java.lang.Object | +--org.apache.commons.collections.FactoryUtils
This class is not normally instantiated. |
static Factory | constantFactory(Object constantToReturn) Creates a Factory that will return the same object each time the factory is used. |
static Factory | 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 | 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. |
public FactoryUtils()
public static Factory constantFactory(Object constantToReturn)
public static Factory exceptionFactory()
public static Factory instantiateFactory(Class classToInstantiate, Class[] paramTypes, Object[] args)
- if the classToInstantiate is null
- if the paramTypes and args don't match
- if the constructor doesn't existpublic static Factory instantiateFactory(Class classToInstantiate)
- if the classToInstantiate is nullpublic static Factory nullFactory()
public static Factory prototypeFactory(Object prototype)
- if the prototype is null
- if the prototype cannot be cloned
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.