public class FactoryUtils
extends java.lang.Object
FactoryUtils
provides reference implementations and utilities
for the Factory functor interface. The supplied factories are:
Constructor and Description |
---|
FactoryUtils()
This class is not normally instantiated.
|
Modifier and Type | Method and Description |
---|---|
static Factory |
constantFactory(java.lang.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(java.lang.Class classToInstantiate)
Creates a Factory that can create objects of a specific type using
a no-args constructor.
|
static Factory |
instantiateFactory(java.lang.Class classToInstantiate,
java.lang.Class[] paramTypes,
java.lang.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(java.lang.Object prototype)
Creates a Factory that will return a clone of the same prototype object
each time the factory is used.
|
public static Factory exceptionFactory()
ExceptionFactory
public static Factory nullFactory()
ConstantFactory
public static Factory constantFactory(java.lang.Object constantToReturn)
constantToReturn
- the constant object to return each time in the factoryconstant
factory.ConstantFactory
public static Factory prototypeFactory(java.lang.Object prototype)
prototype
- the object to clone each time in the factoryprototype
factoryjava.lang.IllegalArgumentException
- if the prototype is nulljava.lang.IllegalArgumentException
- if the prototype cannot be clonedPrototypeFactory
public static Factory instantiateFactory(java.lang.Class classToInstantiate)
classToInstantiate
- the Class to instantiate each time in the factoryreflection
factoryjava.lang.IllegalArgumentException
- if the classToInstantiate is nullInstantiateFactory
public static Factory instantiateFactory(java.lang.Class classToInstantiate, java.lang.Class[] paramTypes, java.lang.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 nullreflection
factoryjava.lang.IllegalArgumentException
- if the classToInstantiate is nulljava.lang.IllegalArgumentException
- if the paramTypes and args don't matchjava.lang.IllegalArgumentException
- if the constructor doesn't existInstantiateFactory
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"