dk.rode.thesis.proxy
Class ImmutableSequence<E>
java.lang.Object
dk.rode.thesis.decorator.SequenceDecorator<E>
dk.rode.thesis.proxy.NonResettableSequence<E>
dk.rode.thesis.proxy.ImmutableSequence<E>
- Type Parameters:
E
- The type of values delivered by this sequence.
- All Implemented Interfaces:
- Sequence<E>, Copyable<Sequence<E>>, StrictCopyable<Sequence<E>>, Stringable<Sequence<E>>
@ParticipantUsage(value="Subject",
type=Sequence.class)
@Participant(value="Proxy")
public class ImmutableSequence<E>
- extends NonResettableSequence<E>
- implements Sequence<E>
An immutable sequence ensures that invocations of
NonResettableSequence.reset()
, next()
, and copy()
are ignored
for the proxied sequence
if and only if
the proxied sequence is accessed through the proxy only.
The copy()
method returns the same immutable
sequence.
An immutable sequence exhibits the same bounded
,
consistent
, and unique
properties as the proxied sequence.
Implementation notes:
An immutable sequence corresponds to a protection proxy as described
by Gamma et al. [Gamma95, p.208].
- Author:
- Gunni Rode / rode.dk
- See Also:
SequenceProxyFactory.getImmutableSequence(Sequence)
Methods inherited from class dk.rode.thesis.decorator.SequenceDecorator |
bounded, consistent, current, equals, getSequence, getStringablePolicy, hashCode, state, toString, toString, unique |
ImmutableSequence
public ImmutableSequence(@Participant(value="RealSubject")
Sequence<E> sequence)
- Constructor.
- Parameters:
sequence
- The sequence to proxy; cannot be null.
- Throws:
NullPointerException
- If sequence
is null.
copy
public ImmutableSequence<E> copy()
- Returns this sequence.
- Specified by:
copy
in interface Sequence<E>
- Specified by:
copy
in interface Copyable<Sequence<E>>
- Overrides:
copy
in class NonResettableSequence<E>
- Returns:
- This sequence; never null.
next
public final E next()
- Does not advance the proxied sequence.
- Specified by:
next
in interface Sequence<E>
- Overrides:
next
in class SequenceDecorator<E>
- Returns:
- The current element; never null.
- See Also:
Sequence.current()
,
Sequence.state()
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.