Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.abstractfactory
Class PrototypicalAbstractionFactory<E>

java.lang.Object
  extended by dk.rode.thesis.abstractfactory.PrototypicalAbstractionFactory<E>
Type Parameters:
E - The type of values delivered by the created abstractions.
All Implemented Interfaces:
AbstractionFactory<E>

@ParticipantUsage(value="ConcreteProduct",
                  type=SequenceAbstraction.class)
@Participant(value="ConcreteFactory")
public class PrototypicalAbstractionFactory<E>
extends Object
implements AbstractionFactory<E>

A prototypical abstraction factory creates sequence abstractions based on a prototype supplied at construction time.

Created abstractions will be initialised if the prototype supplied at construction time was initialised.

This factory is thread-safe.

Author:
Gunni Rode / rode.dk
See Also:
MemorizableAbstractionFactory, SynchronisedAbstractionFactory

Field Summary
private  SequenceAbstraction<E> prototype
          The prototypical sequence abstraction to use.
 
Constructor Summary
PrototypicalAbstractionFactory(SequenceAbstraction<E> prototype)
          Constructor.
 
Method Summary
 SequenceAbstraction<E> createAbstraction()
          Creates a new sequence abstraction instance.
 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

prototype

private final SequenceAbstraction<E> prototype
The prototypical sequence abstraction to use.

The abstraction may or may not have been initialised.

Never null.

Constructor Detail

PrototypicalAbstractionFactory

public PrototypicalAbstractionFactory(SequenceAbstraction<E> prototype)
Constructor.

The abstraction supplied as prototype is copied, so modifying it from an external context will not affect this factory (unless prototype is a singleton). This factory will not change prototype.

Parameters:
prototype - The prototypical abstraction to use; cannot be null.
Throws:
NullPointerException - If prototype is null.
Method Detail

createAbstraction

public SequenceAbstraction<E> createAbstraction()
Description copied from interface: AbstractionFactory
Creates a new sequence abstraction instance.

Depending on the actual factory implementation, the returned abstraction may be initialised. If so, no implementation need be set.

Specified by:
createAbstraction in interface AbstractionFactory<E>
Returns:
A new sequence abstraction instance; never null.

toString

public String toString()
Returns the string representation of this factory.

Overrides:
toString in class Object
Returns:
The string representation; never null.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.