com.natpryce.makeiteasy.sequence
Class ChainedSequence<T>

java.lang.Object
  extended by com.natpryce.makeiteasy.sequence.ChainedSequence<T>
Type Parameters:
T - the type of the value
All Implemented Interfaces:
Donor<T>

public abstract class ChainedSequence<T>
extends Object
implements Donor<T>

A sequence of values, each of which is calculated from the previous value in the sequence.


Constructor Summary
ChainedSequence()
           
 
Method Summary
protected abstract  T firstValue()
          Returns the first value in the sequence.
 T value()
          Donate the value.
protected abstract  T valueAfter(T prevValue)
          Return the value after a given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChainedSequence

public ChainedSequence()
Method Detail

value

public T value()
Description copied from interface: Donor
Donate the value.

Specified by:
value in interface Donor<T>
Returns:
the value donated

firstValue

protected abstract T firstValue()
Returns the first value in the sequence. The result must not be null.

Returns:
the first value.

valueAfter

protected abstract T valueAfter(T prevValue)
Return the value after a given value. The result must not be null.

Parameters:
prevValue - the previous value
Returns:
the value after prevValue in this sequence.


Copyright © 2010. All Rights Reserved.