edu.neu.ccs.demeterf.lib
Class Option<X>

java.lang.Object
  extended by edu.neu.ccs.demeterf.lib.Option<X>
Direct Known Subclasses:
None, Some

public abstract class Option<X>
extends java.lang.Object

Represents an Optional instance, similar to ML/Haskell Option types. Subclasses Some/None should not be used directly, please Option.some(...) and Option.none() to create them.


Constructor Summary
Option()
           
 
Method Summary
abstract
<Y> Option<Y>
apply(List.Map<X,Y> m)
          Apply a function to the contained object in this Option if it exists
abstract  X inner()
          Get the inner instance that this Option contains
abstract  boolean isSome()
          Does this Option exist?
static
<X> Option<X>
none()
          Create an Option that is not there (nothing)
static
<X> Option<X>
some(X x)
          Create an Option that exists.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Option

public Option()
Method Detail

some

public static <X> Option<X> some(X x)
Create an Option that exists.


none

public static <X> Option<X> none()
Create an Option that is not there (nothing)


isSome

public abstract boolean isSome()
Does this Option exist?


inner

public abstract X inner()
Get the inner instance that this Option contains


apply

public abstract <Y> Option<Y> apply(List.Map<X,Y> m)
Apply a function to the contained object in this Option if it exists