org.javimmutable.collections.common
Class EmptySequence<T>

java.lang.Object
  extended by org.javimmutable.collections.common.EmptySequence<T>
Type Parameters:
T -
All Implemented Interfaces:
Sequence<T>

@Immutable
public class EmptySequence<T>
extends Object
implements Sequence<T>

Singleton Sequence implementation for an empty sequence.


Constructor Summary
EmptySequence()
           
 
Method Summary
 T getHead()
          Accesses the first value in the Sequence.
 Sequence<T> getTail()
          Accesses the rest of the Sequence.
 boolean isEmpty()
          Determines if this is the end of the Sequence.
static
<T> Sequence<T>
of()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmptySequence

public EmptySequence()
Method Detail

of

public static <T> Sequence<T> of()

isEmpty

public boolean isEmpty()
Description copied from interface: Sequence
Determines if this is the end of the Sequence. When try the Sequence is empty and getHead() cannot be called. getTail() can still be called but will always return an empty Sequence once isEmpty() returns true.

Specified by:
isEmpty in interface Sequence<T>
Returns:

getHead

public T getHead()
Description copied from interface: Sequence
Accesses the first value in the Sequence.

Specified by:
getHead in interface Sequence<T>
Returns:

getTail

@Nonnull
public Sequence<T> getTail()
Description copied from interface: Sequence
Accesses the rest of the Sequence.

Specified by:
getTail in interface Sequence<T>
Returns:


Copyright © 2014 Burton Computer Corporation. All rights reserved.