|
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.factorymethod.CommandCreator<E,Sequence.State> dk.rode.thesis.factorymethod.SequenceCommandCreator<E> dk.rode.thesis.factorymethod.EvilSequenceCommandCreator<E>
E
- The type of values delivered by created commands (and thus sequences).@Participant(value="ConcreteCreator") public class EvilSequenceCommandCreator<E>
An evil sequence command creator is a test creator
that flips the functionality offered by the sequence command
creator
, and may decide to
return a new evil
command as a default command.
This creator can create the following commands based on the supplied internal sequence state:
Sequence.State.NORMAL
:
creates a new ResetCommand
instance.
Sequence.State.RESET
:
creates a new NextCommand
instance.
NullCommand
or or
an EvilCommand
is returned.
An evil sequence command creator is stateless and thread-safe.
Implementation notes:
By throwing exceptions in the factory methods, we test the full functionality
of the CommandCreator.getCommand(Sequence, Object)
method.
Constructor Summary | |
---|---|
EvilSequenceCommandCreator()
No-arg constructor. |
Method Summary | |
---|---|
protected Command<E> |
create(Sequence<E> sequence,
Sequence.State state)
Factory method to create a new command of the
type specified by the token supplied as token . |
protected EvilCommand<E> |
createDefault(Sequence<E> sequence)
Factory method to create a new default command in case the normal command creation
failed. |
Methods inherited from class dk.rode.thesis.factorymethod.CommandCreator |
---|
equals, getCommand, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public EvilSequenceCommandCreator()
Method Detail |
---|
protected Command<E> create(Sequence<E> sequence, Sequence.State state) throws Exception
CommandCreator
command
of the
type specified by the token supplied as token
.
The sequence
set as the receiver is supplied
as sequence
.
create
in class SequenceCommandCreator<E>
sequence
- The sequence; never null.state
- The token identifying the type of command to create;
can be null.
CommandCreator.getCommand(Sequence, Object)
.
Exception
- If the creation fails; if so, a default (or null)
command will be returned by getCommand
.CommandCreator.createDefault(Sequence)
protected EvilCommand<E> createDefault(Sequence<E> sequence) throws Exception
CommandCreator
normal
command creation
failed.
createDefault
in class CommandCreator<E,Sequence.State>
sequence
- The sequence; never null.
CommandCreator.getCommand(Sequence, Object)
.
This implementation returns a new NullCommand
.
Exception
- If the creation fails; if so, a null command
will be returned by getCommand
.
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |