|
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<Integer>
dk.rode.thesis.facade.RandomSequence
@Participant(value="SubsystemClass") public class RandomSequence
A random sequence returns a pseudo integer random number
with each call to next() between [0, maximum], where
maximum is supplied at construction time.
A random sequence is bounded, but
inconsistent and not
unique.
UnboundedRandomSequence| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence |
|---|
Sequence.State |
| Field Summary | |
|---|---|
private int |
maximum
The maximum random number delivered by this sequence. |
private Random |
random
The random generator used. |
private int |
sequence
The current random sequence number. |
| Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence |
|---|
state |
| Constructor Summary | |
|---|---|
RandomSequence(int maximum)
Constructor. |
|
RandomSequence(RandomSequence sequence)
Copy constructor. |
|
| Method Summary | |
|---|---|
boolean |
bounded()
Returns true. |
boolean |
consistent()
Returns false. |
RandomSequence |
copy()
Returns a copy of this sequence that will start at the same sequence index as this sequence. |
Integer |
current()
Returns the current element from this sequence. |
Integer |
next()
Returns the next element from this sequence. |
void |
reset()
Resets this sequence to start over if it is consistent. |
boolean |
unique()
Returns false. |
| 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 |
| Field Detail |
|---|
private final int maximum
private final Random random
Never null.
private int sequence
Range: [0, maximum].
| Constructor Detail |
|---|
public RandomSequence(int maximum)
maximum - The maximum random value. Must be larger than 1.
IllegalArgumentException - If max is smaller than 1.public RandomSequence(RandomSequence sequence)
sequence - The sequence to copy; cannot be null.
NullPointerException - If sequence is null.| Method Detail |
|---|
public boolean bounded()
bounded in interface Sequence<Integer>Sequence.unique()public boolean consistent()
consistent in interface Sequence<Integer>public RandomSequence copy()
Sequence
copy in interface Sequence<Integer>copy in interface Copyable<Sequence<Integer>>public Integer 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<Integer>public Integer next()
Sequence
next in interface Sequence<Integer>Sequence.current(),
Sequence.state()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()
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 | ||||||||