edu.rice.cs.plt.tuple
Class Wrapper<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.Wrapper<T>
All Implemented Interfaces:
Thunk<T>, Serializable
Direct Known Subclasses:
IdentityWrapper

public class Wrapper<T>
extends Option<T>
implements Thunk<T>

An arbitrary 1-tuple; overrides toString(), equals(Object), and Tuple.hashCode().

See Also:
Serialized Form

Field Summary
protected  T _value
           
 
Constructor Summary
Wrapper(T value)
           
 
Method Summary
<Ret> Ret
apply(OptionVisitor<? super T,? extends Ret> visitor)
          Calls the appropriate case in the visitor.
 boolean equals(Object o)
           
static
<T> Lambda<T,Wrapper<T>>
factory()
          Produce a lambda that invokes the constructor
protected  int generateHashCode()
           
 boolean isSome()
          Determine whether this Option is a "some" case.
static
<T> Wrapper<T>
make(T value)
          Call the constructor (allows T to be inferred)
 String toString()
           
 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.
 T value()
           
 
Methods inherited from class edu.rice.cs.plt.tuple.Option
isNone, none, some, 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

_value

protected final T _value
Constructor Detail

Wrapper

public Wrapper(T value)
Method Detail

value

public T value()
Specified by:
value in interface Thunk<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>

apply

public <Ret> Ret apply(OptionVisitor<? super T,? extends Ret> visitor)
Description copied from class: Option
Calls the appropriate case in the visitor.

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>

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object
Returns:
true iff this is of the same class as o, and the wrapped values are equal (according to equals)

generateHashCode

protected int generateHashCode()
Specified by:
generateHashCode in class Tuple

make

public static <T> Wrapper<T> make(T value)
Call the constructor (allows T to be inferred)


factory

public static <T> Lambda<T,Wrapper<T>> factory()
Produce a lambda that invokes the constructor