Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.decorator
Class DuplexDecorator

java.lang.Object
  extended by dk.rode.thesis.decorator.SequenceDecorator<String>
      extended by dk.rode.thesis.decorator.DuplexDecorator
All Implemented Interfaces:
Sequence<String>, Copyable<Sequence<String>>, StrictCopyable<Sequence<String>>, Stringable<Sequence<String>>

@Participant(value="ConcreteDecorator")
public class DuplexDecorator
extends SequenceDecorator<String>
implements Sequence<String>

A duplex sequence decorator returns the String value returned by the decorated sequence concatenated with the same value, for example x -> xx.

Only sequences returning strings can be decorated.

The default stringable policy used is DecoratedPolicy.HIDDEN.

Author:
Gunni Rode / rode.dk

Nested Class Summary
 
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence
Sequence.State
 
Field Summary
 
Fields inherited from class dk.rode.thesis.decorator.SequenceDecorator
sequence
 
Constructor Summary
DuplexDecorator(Sequence<String> sequence)
          Constructor.
 
Method Summary
 DuplexDecorator copy()
          Returns a copy of this sequence that will start at the same sequence index as this sequence.
 String current()
          Returns the current element from this sequence.
 String next()
          Returns the next element from this sequence.
 
Methods inherited from class dk.rode.thesis.decorator.SequenceDecorator
bounded, consistent, equals, getSequence, getStringablePolicy, hashCode, reset, state, toString, toString, unique
 
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
bounded, consistent, reset, state, unique
 
Methods inherited from interface dk.rode.thesis.strategy.Stringable
getStringablePolicy, toString
 

Constructor Detail

DuplexDecorator

public DuplexDecorator(@Participant(value="ConcreteComponent")
                       Sequence<String> sequence)
Constructor.

Parameters:
sequence - The sequence to decorate; cannot be null.
Throws:
NullPointerException - If sequence is null.
Method Detail

copy

public DuplexDecorator copy()
Description copied from interface: Sequence
Returns a copy of this sequence that will start at the same sequence index as this sequence.

Specified by:
copy in interface Sequence<String>
Specified by:
copy in interface Copyable<Sequence<String>>
Returns:
A copy of this sequence; never null.

current

public String current()
Description copied from interface: Sequence
Returns the current element from this sequence.

This method can be invoked even if Sequence.next() has not been invoked yet, thus delivering the initial value of this sequence.

Specified by:
current in interface Sequence<String>
Overrides:
current in class SequenceDecorator<String>
Returns:
The current element; never null.

next

public String next()
Description copied from interface: Sequence
Returns the next element from this sequence.

Specified by:
next in interface Sequence<String>
Overrides:
next in class SequenceDecorator<String>
Returns:
The next element; never null.
See Also:
Sequence.current(), Sequence.state()

Gunni Rode / rode.dk

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.