CreatedType
- The type created by the factory.@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.","This is definitely the hazard of Justin with time on his hands ;"}) public class PrototypeFactory<CreatedType extends CloneableSerializable> extends AbstractCloneableSerializable implements Factory<CreatedType>
PrototypeFactory
class implements a Factory
that uses a
prototype object to create new objects from by cloning it.Modifier and Type | Field and Description |
---|---|
protected CreatedType |
prototype
The prototype to create clones from.
|
Constructor and Description |
---|
PrototypeFactory()
Creates a new
PrototypeFactory with no prototype. |
PrototypeFactory(CreatedType prototype)
Creates a new
PrototypeFactory with the given prototype. |
PrototypeFactory(PrototypeFactory<? extends CreatedType> other)
Creates a new copy of a
PrototypeFactory . |
Modifier and Type | Method and Description |
---|---|
PrototypeFactory<CreatedType> |
clone()
Clones this
PrototypeFactory . |
CreatedType |
create()
Creates a new object by calling the clone method on the prototype in the
factory.
|
static <T extends CloneableSerializable> |
createFactory(T prototype)
A convenience method for creating prototype factories.
|
CreatedType |
getPrototype()
Gets the prototype object that is cloned to create new objects.
|
void |
setPrototype(CreatedType prototype)
Sets the prototype object that is cloned to create new objects.
|
protected CreatedType extends CloneableSerializable prototype
public PrototypeFactory()
PrototypeFactory
with no prototype.public PrototypeFactory(CreatedType prototype)
PrototypeFactory
with the given prototype.prototype
- The prototype to create clones from.public PrototypeFactory(PrototypeFactory<? extends CreatedType> other)
PrototypeFactory
.other
- The other factory to copy.public PrototypeFactory<CreatedType> clone()
PrototypeFactory
.clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
PrototypeFactory
.public CreatedType create()
create
in interface Factory<CreatedType extends CloneableSerializable>
public CreatedType getPrototype()
public void setPrototype(CreatedType prototype)
prototype
- The prototype object.public static <T extends CloneableSerializable> PrototypeFactory<T> createFactory(T prototype)
T
- The type of the prototype object to create a factory for.prototype
- The prototype object.