FactoryUtils provides reference implementations and utilities
for the Factory functor interface. The supplied factories are:
Since v4.1 only factories which are considered to be safe are Serializable. Factories considered to be unsafe for serialization are:
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static < the type that the factory creates T> Factory | Returns: theconstant factory.the constant object to return each time in the factory constantToReturn)Creates a Factory that will return the same object each time the factory is used. |
| public static < the type that the factory creates T> Factory | |
| public static < the type that the factory creates T> Factory | Returns: thereflection factorythe Class to instantiate each time in the factory classToInstantiate)Creates a Factory that can create objects of a specific type using a no-args constructor. |
| public static < the type that the factory creates T> Factory | Returns: thereflection factorythe Class to instantiate each time in the factory classToInstantiate, final Class<?>[] parameter types for the constructor, can be null paramTypes, final Object[] the arguments to pass to the constructor, can be null args)Creates a Factory that can create objects of a specific type using the arguments specified to this method. |
| public static < the "type" of null object the factory should return. T> Factory | Returns: the factoryGets a Factory that will return null each time the factory is used. |
| public static < the type that the factory creates T> Factory | prototypeFactory(final T
the object to clone each time in the factory prototype)Creates a Factory that will return a clone of the same prototype object each time the factory is used. |
| FactoryUtils | back to summary |
|---|---|
| private FactoryUtils() This class is not normally instantiated. | |
| constantFactory | back to summary |
|---|---|
| public static <T> Factory 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.
| |
| exceptionFactory | back to summary |
|---|---|
| public static <T> Factory Gets a Factory that always throws an exception. This could be useful during testing as a placeholder.
| |
| instantiateFactory | back to summary |
|---|---|
| public static <T> Factory Creates a Factory that can create objects of a specific type using a no-args constructor.
| |
| instantiateFactory | back to summary |
|---|---|
| public static <T> Factory Creates a Factory that can create objects of a specific type using the arguments specified to this method.
| |
| nullFactory | back to summary |
|---|---|
| public static <T> Factory Gets a Factory that will return null each time the factory is used. This could be useful during testing as a placeholder.
| |
| prototypeFactory | back to summary |
|---|---|
| public static <T> Factory 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):
| |