
Prototype

Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
Source Code
/** * Declares interface for cloning itself. * @role __Prototype */ public interface Prototype { Prototype createCopy();} /** * Implements an operation for cloning itself. */ public class ConcretePrototype1 implements Prototype { protected ConcretePrototype1(ConcretePrototype1 prototype) { // initialize new copy with prototype } public Prototype createCopy() { return new ConcretePrototype1(this); } } /** * Implements an operation for cloning itself. */ public class ConcretePrototype1 implements Prototype { protected ConcretePrototype1(ConcretePrototype1 prototype) { // initialize new copy with prototype } public Prototype createCopy() { return new ConcretePrototype1(this); } }