Package org.apache.commons.collections
Class FactoryUtils
java.lang.Object
org.apache.commons.collections.FactoryUtils
Deprecated.
Apache Commons Collections version 3.x is being deprecated from AEMaaCS. The upgraded version 4.4 of Commons Collections is already included as replacement. Customers are advised to upgrade to this version of the library. Please note: the package name was changed to org.apache.commons.collections4. Further note that there are AEM APIs currently exposing the old collections classes; these will be updated in upcoming releases.
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
- Since:
- Commons Collections 3.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FactoryconstantFactory(Object constantToReturn) Deprecated.Creates a Factory that will return the same object each time the factory is used.static FactoryDeprecated.Gets a Factory that always throws an exception.static FactoryinstantiateFactory(Class classToInstantiate) Deprecated.Creates a Factory that can create objects of a specific type using a no-args constructor.static FactoryinstantiateFactory(Class classToInstantiate, Class[] paramTypes, Object[] args) Deprecated.Creates a Factory that can create objects of a specific type using the arguments specified to this method.static FactoryDeprecated.Gets a Factory that will return null each time the factory is used.static FactoryprototypeFactory(Object prototype) Deprecated.Creates a Factory that will return a clone of the same prototype object each time the factory is used.
-
Constructor Details
-
FactoryUtils
public FactoryUtils()Deprecated.This class is not normally instantiated.
-
-
Method Details
-
exceptionFactory
Deprecated.Gets a Factory that always throws an exception. This could be useful during testing as a placeholder.- Returns:
- the factory
- See Also:
-
nullFactory
Deprecated.Gets a Factory that will return null each time the factory is used. This could be useful during testing as a placeholder.- Returns:
- the factory
- See Also:
-
constantFactory
Deprecated.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.- Parameters:
constantToReturn- the constant object to return each time in the factory- Returns:
- the
constantfactory. - See Also:
-
prototypeFactory
Deprecated.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
- Parameters:
prototype- the object to clone each time in the factory- Returns:
- the
prototypefactory - Throws:
IllegalArgumentException- if the prototype is nullIllegalArgumentException- if the prototype cannot be cloned- See Also:
-
instantiateFactory
Deprecated.Creates a Factory that can create objects of a specific type using a no-args constructor.- Parameters:
classToInstantiate- the Class to instantiate each time in the factory- Returns:
- the
reflectionfactory - Throws:
IllegalArgumentException- if the classToInstantiate is null- See Also:
-
instantiateFactory
public static Factory instantiateFactory(Class classToInstantiate, Class[] paramTypes, Object[] args) Deprecated.Creates a Factory that can create objects of a specific type using the arguments specified to this method.- Parameters:
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- Returns:
- the
reflectionfactory - Throws:
IllegalArgumentException- if the classToInstantiate is nullIllegalArgumentException- if the paramTypes and args don't matchIllegalArgumentException- if the constructor doesn't exist- See Also:
-