|
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.Objectdk.rode.thesis.meta.model.AbstractSequence<E>
dk.rode.thesis.meta.model.ArraySequence<E>
E - The type of values delivered by this sequence.public abstract class ArraySequence<E>
A simple abstract array sequence to deliver all the
entries in a given array, in order. An invocation of
next() returns the next element in the array.
Sub-classes need only supply the actual array on construction.
An array sequence is bounded,
consistent, and unless otherwise
specified unique().
Array sequences are by default equal to any array sequence of the same type using an equivalent array that is at the same sequence index.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence |
|---|
Sequence.State |
| Field Summary | |
|---|---|
protected E[] |
elements
The array used. |
protected int |
index
The current index. |
| Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence |
|---|
state |
| Constructor Summary | |
|---|---|
protected |
ArraySequence(ArraySequence<E> sequence)
Copy constructor. |
protected |
ArraySequence(E... array)
Constructor, which creates this sequence to use the array supplied as array. |
| 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. |
E |
current()
Returns the current element from this sequence. |
boolean |
equals(Object object)
Returns true if object is an array sequence having the
same type as this array sequence, using an equivalent
array, and is at the same sequence index, false if not. |
int |
hashCode()
Returns the hash code of this sequence. |
E |
next()
Returns the next element from this sequence. |
void |
reset()
Resets this sequence to start over if it is consistent. |
int |
size()
Returns the number of elements in this array sequence. |
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, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface dk.rode.thesis.meta.model.Sequence |
|---|
copy, state |
| Methods inherited from interface dk.rode.thesis.strategy.Stringable |
|---|
getStringablePolicy, toString |
| Field Detail |
|---|
protected final E[] elements
Never null, and never empty.
protected int index
Invariant: 0 <= index < elements.length
| Constructor Detail |
|---|
protected ArraySequence(ArraySequence<E> sequence)
The array is not copied, but used as is. This sequence starts
at the current index of sequence.
sequence - The array sequence to copy; cannot be null.
NullPointerException - If sequence is null.protected ArraySequence(E... array)
array. The array is not copied, but used as is.
array - The array; cannot be null or empty.
NullPointerException - If array is null.
IllegalArgumentException - If array is empty.| Method Detail |
|---|
public final 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<E>size()public final boolean consistent()
Sequencereset.
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<E>public E current()
Sequence
This method can be invoked even if Sequence.next()
has not been invoked yet, thus delivering the initial
value of this sequence.
current in interface Sequence<E>public boolean equals(Object object)
object is an array sequence having the
same type as this array sequence, using an equivalent
array, and is at the same sequence index, false if not.
equals in class Objectobject - The object to test; can be null.
public int hashCode()
hashCode in class Objectpublic E next()
Sequence
next in interface Sequence<E>Sequence.current(),
Sequence.state()public void reset()
Sequence
If this sequence is consistent, the
sequence will restart.
reset in interface Sequence<E>reset in class AbstractSequence<E>public int size()
public boolean unique()
Sequencereset 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<E>Sequence.consistent()
|
Gunni Rode / rode.dk | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||