|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.rode.thesis.abstractfactory.PrototypicalFactory<T>
T
- The type of values created by this factory.@ParticipantUsage(value="ConcreteProduct", type=StrictCopyable.class) @Participant(value="ConcreteFactory") public class PrototypicalFactory<T extends StrictCopyable<T>>
A prototypical factory creates instances of a specific type of
copyable
type based on a prototype supplied at
construction time.
This factory is thread-safe.
Implementation notes:
Using the Prototype pattern as a means
to create different types of sequences is an, perhaps safer, alternative
to creating sequences using reflection. The Factory
type illustrates
how reflection can be used in the creation process.
PrototypicalRegistry
Field Summary | |
---|---|
private T |
prototype
The prototypical object to use. |
Constructor Summary | |
---|---|
PrototypicalFactory(T prototype)
Constructor. |
Method Summary | |
---|---|
T |
create()
Creates a new instance based on the prototypical object supplied at construction time. |
String |
toString()
Returns the string representation of this factory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final T extends StrictCopyable<T> prototype
Never null.
Constructor Detail |
---|
public PrototypicalFactory(T prototype)
prototype
is copied and this factory keeps no reference
to it.
prototype
- The prototypical object to use; cannot be null.
NullPointerException
- If prototype
is null.Method Detail |
---|
public T create()
public String toString()
toString
in class Object
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |