edu.neu.ccs.demeterf.lib
Class Option<X>
java.lang.Object
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.
Method Summary |
abstract
|
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
|
none()
Create an Option that is not there (nothing) |
static
|
some(X x)
Create an Option that exists. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Option
public Option()
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