CreatedType - The type that the factory creates.@CodeReview(reviewer="Kevin R. Dixon", date="2008-12-02", changesNeeded=false, comments={"I just don\'t think this class will be useful.","However, the implementation is great... if anybody ever finds it useful."}) public class DefaultFactory<CreatedType> extends AbstractCloneableSerializable implements Factory<CreatedType>
DefaultFactory class is a default implementation of the
Factory interface that takes a class as its parameter and uses the
default constructor of the class, called through newInstance(), to create
new objects of that class.| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Class<? extends CreatedType> |
createdClass
The class whose default constructor is used to create new objects.
|
| Constructor and Description |
|---|
DefaultFactory(java.lang.Class<? extends CreatedType> createdClass)
Creates a new
DefaultFactory for the given class. |
| Modifier and Type | Method and Description |
|---|---|
CreatedType |
create()
Creates a new object using the default constructor of the class that
the factory contains.
|
static <T> DefaultFactory<T> |
get(java.lang.Class<T> createdClass)
Gets a new
DefaultFactory for the given class. |
java.lang.Class<? extends CreatedType> |
getCreatedClass()
Gets the class whose default constructor is used to create new objects.
|
void |
setCreatedClass(java.lang.Class<? extends CreatedType> createdClass)
Sets the class whose default constructor is used to create new objects.
|
cloneprotected java.lang.Class<? extends CreatedType> createdClass
public DefaultFactory(java.lang.Class<? extends CreatedType> createdClass)
DefaultFactory for the given class.createdClass - The class whose default constructor is used to create new objects.public CreatedType create()
create in interface Factory<CreatedType>public java.lang.Class<? extends CreatedType> getCreatedClass()
public void setCreatedClass(java.lang.Class<? extends CreatedType> createdClass)
createdClass - The class whose default constructor is used to
create new objects.public static <T> DefaultFactory<T> get(java.lang.Class<T> createdClass)
DefaultFactory for the given class.
The class cannot be null, an interface, or an abstract class and must
have a default constructor.T - The type of the class.createdClass - The class whose default constructor will be used in the factory.DefaultFactory created for the given class.