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

dk.rode.thesis.state
Class EvenSequence

java.lang.Object
  extended by dk.rode.thesis.meta.model.AbstractSequence<Integer>
      extended by dk.rode.thesis.state.StepSequenceImpl
          extended by dk.rode.thesis.state.EvenSequence
All Implemented Interfaces:
Sequence<Integer>, Copyable<Sequence<Integer>>, StrictCopyable<Sequence<Integer>>, StepSequence, Stringable<Sequence<Integer>>

@Participant(value="ConcreteState")
 class EvenSequence
extends StepSequenceImpl

The even sequence represents the state generating even step sequence values.

Author:
Gunni Rode / rode.dk
See Also:
OddSequence

Nested Class Summary
 
Nested classes/interfaces inherited from interface dk.rode.thesis.state.StepSequence
StepSequence.Factory
 
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence
Sequence.State
 
Field Summary
 
Fields inherited from class dk.rode.thesis.state.StepSequenceImpl
current, step
 
Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence
state
 
Constructor Summary
EvenSequence(int step, int value)
          Constructor.
EvenSequence(StepSequenceImpl sequence)
          Copy constructor.
 
Method Summary
 EvenSequence copy()
          Returns a deep copy of this object.
 Integer current()
          Returns the current element from this sequence.
(package private)  StepSequenceImpl flip()
          Flips this sequence from even to odd or vice versa.
 Integer next()
          Returns the next element from this sequence.
 
Methods inherited from class dk.rode.thesis.state.StepSequenceImpl
bounded, consistent, reset, unique
 
Methods inherited from class dk.rode.thesis.meta.model.AbstractSequence
getStringablePolicy, state, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, 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
 

Constructor Detail

EvenSequence

EvenSequence(int step,
             int value)
Constructor.

Parameters:
step - The step; cannot be zero.
value - The initial sequence value.
Throws:
IllegalArgumentException - If step is zero.

EvenSequence

EvenSequence(StepSequenceImpl sequence)
Copy constructor.

Parameters:
sequence - The sequence to copy; never null.
Method Detail

copy

public EvenSequence copy()
Description copied from interface: Copyable
Returns a deep copy of this object.

Returns:
The copy; never null.

current

public Integer current()
Description copied from interface: Sequence
Returns the current element from this sequence.

This method can be invoked even if Sequence.next() has not been invoked yet, thus delivering the initial value of this sequence.

Returns:
The current element; never null.

flip

StepSequenceImpl flip()
Description copied from class: StepSequenceImpl
Flips this sequence from even to odd or vice versa.

Specified by:
flip in class StepSequenceImpl
Returns:
A flipped instance; never null.

next

public Integer next()
Description copied from interface: Sequence
Returns the next element from this sequence.

Returns:
The next element; never null.
See Also:
Sequence.current(), Sequence.state()

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.