|
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.CollectionValueFactory<E>
E
- The type of values generated by created generators.@ParticipantUsage(value="ConcreteProduct", type=SequenceValueGenerator.class) @Participant(value="ConcreteFactory") public class CollectionValueFactory<E extends Serializable>
A collection value factory creates specific SequenceValueCollection
objects based on the supplied type of collection to the creation method.
This factory is thread-safe.
Field Summary | |
---|---|
private ArrayList<E> |
defaultCollection
The default collection to use in case the creation process is not supplied an argument. |
private Class<E> |
type
The type of values stored in the value collection. |
Constructor Summary | |
---|---|
CollectionValueFactory(Class<E> type,
Collection<E> defaultCollection)
Constructor. |
Method Summary | |
---|---|
SequenceValueCollection<E,?> |
createGenerator()
Creates a new sequence value generator using the default argument. |
SequenceValueCollection<E,?> |
createGenerator(Collection<E> collection)
Creates a new sequence value generator, where argument is an
argument used in the creation process of the generator. |
Collection<E> |
getDefaultArgument()
Returns the default argument to use for generator creation in case no argument is supplied to the GeneratorFactory.createGenerator(Object)
method. |
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 ArrayList<E extends Serializable> defaultCollection
Never null.
private final Class<E extends Serializable> type
Never null.
Constructor Detail |
---|
public CollectionValueFactory(Class<E> type, Collection<E> defaultCollection)
type
- The type of values generated by the created generators; cannot be null.defaultCollection
- The default collection to use in case the creation
process is not supplied an argument, but will be
copied before each use; cannot be null.
NullPointerException
- If either argument is null.
IllegalArgumentException
- if defaultCollection
is empty.Method Detail |
---|
public SequenceValueCollection<E,?> createGenerator()
GeneratorFactory
default
argument.
createGenerator
in interface GeneratorFactory<E extends Serializable,Collection<E extends Serializable>>
GeneratorFactory.createGenerator(Object)
,
GeneratorFactory.getDefaultArgument()
public SequenceValueCollection<E,?> createGenerator(Collection<E> collection)
GeneratorFactory
argument
is an
argument used in the creation process of the generator.
createGenerator
in interface GeneratorFactory<E extends Serializable,Collection<E extends Serializable>>
collection
- A context supplied argument to use in the construction of the
generator, if any. If null, the default
argument is used (which may also be null, depending
on the actual implementation).
GeneratorFactory.createGenerator()
public Collection<E> getDefaultArgument()
GeneratorFactory
GeneratorFactory.createGenerator(Object)
method.
getDefaultArgument
in interface GeneratorFactory<E extends Serializable,Collection<E extends Serializable>>
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 |