|
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 |
E
- The type of values delivered by this composite sequence.@ParticipantUsage(value={"Component","Leaf"}, type=Sequence.class) @Participant(value="Composite") public interface CompositeSequence<E>
A composite sequence is a sequence that represents
an number of other contained sequences, possibly composite
as well. Sequence methods are propagated to each contained
sequence in either a depth or breath first manner, determined
via a changeable strategy
.
The value returned by the current()
and
next()
methods is sub-class specific.
Composite sequences are simple containers that do not maintain parent references. Contained sequences do not know they are contained unless this information is stored locally. Hence, graph traversal is top-down only.
Composite sequences are bounded
and
consistent
if each contained sequence is
bound and consistent, respectively, but composite sequences cannot
be guaranteed to be unique
even
if all contained sequences are unique. Hence, composite sequences
are per definition not unique.
Implementation notes:
Any sequence delivering a sequence value of type <? extends E>
can be stored in a composite sequence of type E
. This offers
greater flexibility, while ensuring that all sequences in a composite
sequence will match the E
, and can thus be "concatenated in a
proper fashion", for example appending strings, adding different types
of numbers, etc.
ObservableSequence
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
Sequence.State |
Method Summary | ||
---|---|---|
boolean |
addSequence(Sequence<? extends E> sequence)
Associates the sequence supplied
as sequence to this composite sequence, if
not already. |
|
CompositeStrategy |
getCompositeStrategy()
Return the current strategy used by
this composite sequence to traverse the associated sequence
graph. |
|
List<Sequence<? extends E>> |
getSequences()
Returns the sequences currently
associated with this composite sequence, in order. |
|
|
getSequences(Class<V> clazz)
Returns the sequences currently
associated with this composite sequence, in order,
assignable to the type supplied as clazz . |
|
List<Sequence<? extends E>> |
getSequences(CompositeStrategy strategy,
boolean includeSelf,
Boolean type)
Returns the sequences currently
reachable from this composite sequence, in the
order specified by strategy . |
|
|
getSequences(CompositeStrategy strategy,
boolean includeSelf,
Boolean type,
Class<V> clazz)
Returns the sequences currently
reachable from this composite sequence, in the order
specified by strategy . |
|
boolean |
removeSequence(Sequence<?> sequence)
Removes the sequence supplied
as sequence from this composite sequence, if
associated. |
|
void |
setCompositeStrategy(CompositeStrategy strategy)
Sets the current strategy used by
this composite sequence to traverse the associated sequence
graph to strategy . |
|
int |
size()
Returns the number of sequences associated to this composite sequence. |
Methods inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
bounded, consistent, copy, current, next, reset, state, unique |
Methods inherited from interface dk.rode.thesis.strategy.Stringable |
---|
getStringablePolicy, toString |
Methods inherited from interface java.lang.Iterable |
---|
iterator |
Method Detail |
---|
boolean addSequence(Sequence<? extends E> sequence)
sequence
supplied
as sequence
to this composite sequence, if
not already. If already added, this method does nothing.
sequence
- The sequence to add; cannot be null.
sequence
was added, false if not,
i.e. if already added.
NullPointerException
- If sequence
is null.
IllegalArgumentException
- If sequence
is not
a valid sequence to add to this composite sequence.removeSequence(Sequence)
CompositeStrategy getCompositeStrategy()
strategy
used by
this composite sequence to traverse the associated sequence
graph.
List<Sequence<? extends E>> getSequences()
sequences
currently
associated with this composite sequence, in order. Modifying the returned collection will not affect this sequence.
<V extends Sequence<?>> List<V> getSequences(Class<V> clazz)
sequences
currently
associated with this composite sequence, in order,
assignable to the type supplied as clazz
.
Invoking this method with the Sequence
interface
corresponds to invoking getSequences()
.
Modifying the returned collection will not affect this sequence.
V
- The type of applicable sequences.clazz
- The (super-)class of sequences to include; cannot be null.
clazz
; never null, but can be
empty.
NullPointerException
- If clazz
is null.List<Sequence<? extends E>> getSequences(CompositeStrategy strategy, boolean includeSelf, Boolean type)
sequences
currently
reachable from this composite sequence, in the
order specified by strategy
.
This sequence is included in the returned list if
includeSelf
is true and it matches type
;
type
determines the types of sequences to include in
the returned list:
TRUE
: only composite sequences ("nodes").
FALSE
: only non-composite sequences ("leafs").
If strategy
is null, the default
strategy for this sequence is used.
Modifying the returned collection will not affect this sequence.
strategy
- The strategy dictating the traversal; can be null.includeSelf
- True to include this composite sequence in the
returned list (if it matches type
),
false to exclude.type
- The type of sequences to include in the returned
list; can be null.
<V extends Sequence<?>> List<V> getSequences(CompositeStrategy strategy, boolean includeSelf, Boolean type, Class<V> clazz)
sequences
currently
reachable from this composite sequence, in the order
specified by strategy
. Each sequence included
in the returned list is assignable to the type supplied
as clazz
.
This sequence is included in the returned list if it
matches clazz
and type
; type
determines
the types of sequences to include in the returned list:
TRUE
: only composite sequences ("nodes").
FALSE
: only non-composite sequences ("leafs").
If strategy
is null, the default
strategy for this sequence is used.
Modifying the returned collection will not affect this sequence.
V
- The type of applicable sequences.strategy
- The strategy dictating the traversal; can be null.includeSelf
- True to include this composite sequence in the
returned list (if it matches type
and
clazz
), false to exclude.type
- The type of sequences to include in the returned
list; can be null.clazz
- The (super-)class of sequences to include; cannot be null.
clazz
; never null, but can be
empty.
NullPointerException
- If clazz
is null.boolean removeSequence(Sequence<?> sequence)
sequence
supplied
as sequence
from this composite sequence, if
associated. If not associated, this method does nothing.
sequence
- The sequence to remove; cannot be null.
sequence
was removed, false if not,
i.e. if not previously added.
NullPointerException
- If sequence
is null.addSequence(Sequence)
void setCompositeStrategy(CompositeStrategy strategy)
strategy
used by
this composite sequence to traverse the associated sequence
graph to strategy
.
strategy
- The strategy; can be null, in which case the
default strategy is used.int size()
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |