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

dk.rode.thesis.factorymethod
Class ReversibleSequenceCommandCreator<E>

java.lang.Object
  extended by dk.rode.thesis.factorymethod.CommandCreator<E,Sequence.State>
      extended by dk.rode.thesis.factorymethod.SequenceCommandCreator<E>
          extended by dk.rode.thesis.factorymethod.ReversibleSequenceCommandCreator<E>
Type Parameters:
E - The type of values delivered by created commands (and thus sequences).

@Participant(value="ConcreteCreator")
public class ReversibleSequenceCommandCreator<E>
extends SequenceCommandCreator<E>

A reversible sequence command creator extends the sequence command creator to allow for the creation of reverse commands for reversible sequences.

This creator can create the following commands based on the supplied internal sequence state:

A reversible sequence command creator is stateless and thread-safe.

Author:
Gunni Rode / rode.dk

Constructor Summary
ReversibleSequenceCommandCreator()
          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  LogCommand<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

ReversibleSequenceCommandCreator

public ReversibleSequenceCommandCreator()
No-arg constructor.

Method Detail

create

protected Command<E> create(Sequence<E> sequence,
                            Sequence.State state)
                     throws Exception
Description copied from class: CommandCreator
Factory method to create a new command of the type specified by the token supplied as token.

The sequence set as the receiver is supplied as sequence.

Overrides:
create in class SequenceCommandCreator<E>
Parameters:
sequence - The sequence; never null.
state - The token identifying the type of command to create; can be null.
Returns:
The corresponding command, or null if no such command could be created. If null is returned, a default (on null) command is returned by CommandCreator.getCommand(Sequence, Object).
Throws:
Exception - If the creation fails; if so, a default (or null) command will be returned by getCommand.
See Also:
CommandCreator.createDefault(Sequence)

createDefault

protected LogCommand<E> createDefault(Sequence<E> sequence)
Description copied from class: CommandCreator
Factory method to create a new default command in case the normal command creation failed.

Overrides:
createDefault in class CommandCreator<E,Sequence.State>
Parameters:
sequence - The sequence; never null.
Returns:
A new LogCommand instance; 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.