endrov.util.collection
Class Maybe<E>

java.lang.Object
  extended by endrov.util.collection.Maybe<E>

public class Maybe<E>
extends java.lang.Object

Wrapper around pointer that can be a value and can be null, but need to know in addition if it is set. Corresponds to the Haskell Maybe monad.


Constructor Summary
Maybe()
          Construct a Nothing-value
Maybe(E e)
          Construct a reference to a value
 
Method Summary
 E get()
          Get the value
 boolean hasValue()
          Is there a value?
static
<E> Maybe<E>
just(E e)
          Construct value.
 java.lang.String toString()
          String of value of <> if there is no value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Maybe

public Maybe()
Construct a Nothing-value


Maybe

public Maybe(E e)
Construct a reference to a value

Method Detail

get

public E get()
Get the value


hasValue

public boolean hasValue()
Is there a value?


just

public static <E> Maybe<E> just(E e)
Construct value. Nicer to use than constructor since it infers type


toString

public java.lang.String toString()
String of value of <> if there is no value

Overrides:
toString in class java.lang.Object