edu.rice.cs.plt.tuple
Class Null<T>

java.lang.Object
  extended by edu.rice.cs.plt.tuple.Tuple
      extended by edu.rice.cs.plt.tuple.Option<T>
          extended by edu.rice.cs.plt.tuple.Null<T>
All Implemented Interfaces:
java.io.Serializable

public final class Null<T>
extends Option<T>

An empty tuple. There is only one accessible instance, the INSTANCE singleton, which has arbitrarily-chosen type argument Void (Option<null> would make more sense, but is not expressible). Clients needing a specific kind of Null can perform an unsafe cast on the singleton to produce the desired type (this is done in make()).

See Also:
Serialized Form

Field Summary
static Null<java.lang.Void> INSTANCE
          A singleton null tuple
 
Method Summary
<Ret> Ret
apply(OptionVisitor<? super T,? extends Ret> visitor)
          Invokes visitor.forNone()
 boolean equals(java.lang.Object o)
          Defined in terms of identity (since the singleton is the only accessible instance)
protected  int generateHashCode()
          Defined in terms of identity (since the singleton is the only accessible instance)
 boolean isSome()
          Determine whether this Option is a "some" case.
static
<T> Null<T>
make()
          Return a singleton, cast to the appropriate type.
 java.lang.String toString()
          Produces "()"
 T unwrap()
          Get the value wrapped by this Option, or throw an OptionUnwrapException if there is no wrapped value.
 T unwrap(T forNone)
          Get the value wrapped by this Option, or forNone if there is no wrapped value.
 
Methods inherited from class edu.rice.cs.plt.tuple.Option
comparator, comparator, isNone, none, some, unwrap, wrap
 
Methods inherited from class edu.rice.cs.plt.tuple.Tuple
hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INSTANCE

public static final Null<java.lang.Void> INSTANCE
A singleton null tuple

Method Detail

apply

public <Ret> Ret apply(OptionVisitor<? super T,? extends Ret> visitor)
Invokes visitor.forNone()

Specified by:
apply in class Option<T>

isSome

public boolean isSome()
Description copied from class: Option
Determine whether this Option is a "some" case. Mutually exclusive with Option.isNone().

Specified by:
isSome in class Option<T>

unwrap

public T unwrap()
Description copied from class: Option
Get the value wrapped by this Option, or throw an OptionUnwrapException if there is no wrapped value.

Specified by:
unwrap in class Option<T>

unwrap

public T unwrap(T forNone)
Description copied from class: Option
Get the value wrapped by this Option, or forNone if there is no wrapped value.

Specified by:
unwrap in class Option<T>

toString

public java.lang.String toString()
Produces "()"

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Defined in terms of identity (since the singleton is the only accessible instance)

Overrides:
equals in class java.lang.Object

generateHashCode

protected int generateHashCode()
Defined in terms of identity (since the singleton is the only accessible instance)

Specified by:
generateHashCode in class Tuple

make

public static <T> Null<T> make()
Return a singleton, cast to the appropriate type.