|
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.meta.model.AbstractSequence<Integer> dk.rode.thesis.state.StepSequenceImpl
@Participant(value="State") abstract class StepSequenceImpl
An abstract class representing the basic traits of the
StepSequence
interface.
This class has two sub-classes: one that handles even sequence
values, and one that handles odd values. It is possible to "flip"
between the two types using the flip()
method.
Implementation notes:
This class could implement almost all sequence functionality, but
that is left to the sub-classes to better illustrate that an
different target is used once flipped.
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 | |
---|---|
(package private) int |
current
The current value of this sequence. |
private int |
start
The initial value of this sequence. |
(package private) int |
step
The step value to increase the sequence value with each call to next() . |
Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence |
---|
state |
Constructor Summary | |
---|---|
StepSequenceImpl(int step,
int value)
Constructor. |
|
StepSequenceImpl(StepSequenceImpl sequence)
Copy constructor. |
Method Summary | |
---|---|
boolean |
bounded()
Returns true if this sequence is bounded, i.e. |
boolean |
consistent()
Returns true if this sequence is consistent, i.e. deliver the same values, in order, after restart or reset . |
(package private) abstract StepSequenceImpl |
flip()
Flips this sequence from even to odd or vice versa. |
void |
reset()
Resets this sequence to start over if it is consistent. |
boolean |
unique()
Returns true if this sequence deliver a given sequence value at most one time until reset or restarted. |
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 |
---|
copy, current, next, state |
Methods inherited from interface dk.rode.thesis.strategy.Stringable |
---|
getStringablePolicy, toString |
Field Detail |
---|
int current
private final int start
final int step
next()
. Never zero, but can be negative.
Constructor Detail |
---|
StepSequenceImpl(int step, int value)
step
- The step; cannot be zero.value
- The initial sequence value.
IllegalArgumentException
- If step
is zero.StepSequence.Factory
StepSequenceImpl(StepSequenceImpl sequence)
sequence
- The sequence to copy; cannot be null.
NullPointerException
- If sequence
is zero.Method Detail |
---|
public boolean bounded()
Sequence
The same type of sequence may represent both bounded and
unbounded sequences and the behaviour is determined and fixed
at construction time.
Bounded sequences will restart if they deliver
consistent
values.
bounded
in interface Sequence<Integer>
Sequence.unique()
public boolean consistent()
Sequence
reset
.
Only bounded
consistent sequences will restart.
Consistent sequences need not deliver unique
sequence values.
Instances of the same type of sequences are always consistent or inconsistent; it is determined at design time, not construction time.
consistent
in interface Sequence<Integer>
abstract StepSequenceImpl flip()
public void reset()
Sequence
If this sequence is consistent
, the
sequence will restart.
reset
in interface Sequence<Integer>
reset
in class AbstractSequence<Integer>
public boolean unique()
Sequence
reset
or restarted.
Unbounded
sequences that are unique will never
deliver the same sequence value more than once.
The same type of sequence may represent both unique and not unique sequences and the behaviour is determined and fixed at construction time.
unique
in interface Sequence<Integer>
Sequence.consistent()
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |