org.apache.camel.processor.resequencer
Class Sequence<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.TreeSet<E>
              extended by org.apache.camel.processor.resequencer.Sequence<E>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, NavigableSet<E>, Set<E>, SortedSet<E>

public class Sequence<E>
extends TreeSet<E>

A sorted set of elements with additional methods for obtaining immediate successors and immediate predecessors of a given element in the sequence. Successors and predecessors are calculated by using a SequenceElementComparator.

Version:
See Also:
Serialized Form

Constructor Summary
Sequence(SequenceElementComparator<E> comparator)
          Creates a new Sequence instance.
 
Method Summary
 SequenceElementComparator<E> comparator()
          Returns this sequence's comparator.
 E higher(E e)
          Returns the next higher element in the sequence to the given element.
 E lower(E e)
          Returns the next lower element in the sequence to the given element.
 E predecessor(E e)
          Returns the immediate predecessor of the given element in this sequence or null if no predecessor exists.
 E successor(E e)
          Returns the immediate successor of the given element in this sequence or null if no successor exists.
 
Methods inherited from class java.util.TreeSet
add, addAll, ceiling, clear, clone, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, isEmpty, iterator, last, pollFirst, pollLast, remove, size, subSet, subSet, tailSet, tailSet
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

Sequence

public Sequence(SequenceElementComparator<E> comparator)
Creates a new Sequence instance.

Parameters:
comparator - a strategy for comparing elements of this sequence.
Method Detail

predecessor

public E predecessor(E e)
Returns the immediate predecessor of the given element in this sequence or null if no predecessor exists.

Parameters:
e - an element which is compared to elements of this sequence.
Returns:
an element of this sequence or null.

successor

public E successor(E e)
Returns the immediate successor of the given element in this sequence or null if no successor exists.

Parameters:
e - an element which is compared to elements of this sequence.
Returns:
an element of this sequence or null.

comparator

public SequenceElementComparator<E> comparator()
Returns this sequence's comparator.

Specified by:
comparator in interface SortedSet<E>
Overrides:
comparator in class TreeSet<E>
Returns:
this sequence's comparator.

higher

public E higher(E e)
Returns the next higher element in the sequence to the given element. If the given element doesn't exist or if it is the last element in the sequence null is returned. Please note that this method is provided for compatibility with Java 5 SE. On a Java 6 SE platform the same method implemented by the TreeSet class should be used for better performance.

Specified by:
higher in interface NavigableSet<E>
Overrides:
higher in class TreeSet<E>
Parameters:
e - an element which is compared to elements of this sequence.
Returns:
an element of this sequence or null.

lower

public E lower(E e)
Returns the next lower element in the sequence to the given element. If the given element doesn't exist or if it is the first element in the sequence null is returned. Please note that this method is provided for compatibility with Java 5 SE. On a Java 6 SE platform the same method implemented by the TreeSet class should be used for better performance.

Specified by:
lower in interface NavigableSet<E>
Overrides:
lower in class TreeSet<E>
Parameters:
e - an element which is compared to elements of this sequence.
Returns:
an element of this sequence or null.


Apache CAMEL