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

dk.rode.thesis.prototype
Class CountdownSequence

java.lang.Object
  extended by dk.rode.thesis.meta.model.AbstractSequence<E>
      extended by dk.rode.thesis.meta.model.ArraySequence<String>
          extended by dk.rode.thesis.prototype.CountdownSequence
All Implemented Interfaces:
Sequence<String>, Copyable<Sequence<String>>, StrictCopyable<Sequence<String>>, Stringable<Sequence<String>>

@Participant(value="ConcretePrototype")
public class CountdownSequence
extends ArraySequence<String>

A non-copyable count-down sequence is a singleton sequence used for count-downs:

   Five, Four, Three, Two, One, FIRE! 
 
Invoking clone() will always throw a CloneNotSupportedException, and the copy() method returns the same instance.

A count-down sequence is bounded, consistent, and unique.

Author:
Gunni Rode / rode.dk

Nested Class Summary
 
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence
Sequence.State
 
Field Summary
private static String[] elements
          The various elements in a count-down sequence.
private static CountdownSequence instance
          Single instance of the sequence, initialised thread-safe at class loading time.
 
Fields inherited from class dk.rode.thesis.meta.model.ArraySequence
index
 
Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence
state
 
Constructor Summary
private CountdownSequence()
          No-arg constructor.
 
Method Summary
 CountdownSequence clone()
          Always throws a CloneNotSupportedException.
 CountdownSequence copy()
          Returns a copy of this sequence that will start at the same sequence index as this sequence.
static CountdownSequence getInstance()
          Returns the CountdownSequence instance to use.
 
Methods inherited from class dk.rode.thesis.meta.model.ArraySequence
bounded, consistent, current, equals, hashCode, next, reset, size, unique
 
Methods inherited from class dk.rode.thesis.meta.model.AbstractSequence
getStringablePolicy, state, toString, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface dk.rode.thesis.meta.model.Sequence
state
 
Methods inherited from interface dk.rode.thesis.strategy.Stringable
getStringablePolicy, toString
 

Field Detail

elements

private static final String[] elements
The various elements in a count-down sequence.


instance

private static final CountdownSequence instance
Single instance of the sequence, initialised thread-safe at class loading time.

Never null.

Constructor Detail

CountdownSequence

private CountdownSequence()
No-arg constructor.

Method Detail

clone

public CountdownSequence clone()
                        throws CloneNotSupportedException
Always throws a CloneNotSupportedException.

Overrides:
clone in class Object
Returns:
Never returns.
Throws:
CloneNotSupportedException - Always thrown.

copy

public CountdownSequence copy()
Description copied from interface: Sequence
Returns a copy of this sequence that will start at the same sequence index as this sequence.

Returns:
A copy of this sequence; never null.

getInstance

public static final CountdownSequence getInstance()
Returns the CountdownSequence instance to use.

Returns:
The sequence; 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.