| Modifier and Type | Class and Description |
|---|---|
static class |
Option.EMatch<A>
Effect match.
|
static interface |
Option.Match<A,B> |
| Modifier and Type | Method and Description |
|---|---|
<B> Option<Tuple<A,B>> |
and(Option<B> b) |
<B> Option<B> |
andThen(Function0<Option<B>> some)
Lazy version of
andThen(Option). |
<B> Option<B> |
andThen(Option<B> some)
If this is some return
some. |
<B> Option<B> |
andThenV(B some)
If this is some return
some. |
<B> Option<B> |
andThenV(Function0<B> some)
Lazy version of
andThenV(Object). |
abstract <B> Option<B> |
bind(Function<A,Option<B>> f)
Monadic bind operation
m a -> (a -> m b) -> m b. |
static Function<String,Boolean> |
eq(String compare)
Create an equals function.
|
abstract boolean |
equals(Object o) |
static <A> Function0<A> |
error(String message)
Deprecated.
use
orError(Throwable) or orElse(Function0) instead since it saves the need for
creating new objects just for the sake of type soundness. Java unfortunately lacks a bottom type. |
<B> Option<B> |
flatMap(Function<A,Option<B>> f) |
abstract <B> Option<B> |
fmap(Function<? super A,? extends B> f) |
<B> B |
fold(Function<A,B> some,
Function0<B> none)
Safe decomposition of the option type using functions.
|
abstract <B> B |
fold(Option.Match<A,B> visitor)
Safe decomposition of the option type.
|
abstract Option<A> |
foreach(Function<? super A,Void> f) |
static <A> Option<A> |
fromOpt(com.entwinemedia.fn.data.Opt<A> a)
Convert an
Opt into an Option. |
abstract A |
get()
Get the contained value or throw an exception.
|
abstract A |
getOrElse(A none)
Get the contained value in case of being "some" or return parameter
none otherwise. |
abstract A |
getOrElse(Function0<A> none)
Get the contained value in case of being "some" or return the result of evaluating
none otherwise. |
abstract A |
getOrElseNull()
To interface with legacy applications or frameworks that still use
null values. |
abstract int |
hashCode() |
Option<A> |
inv(A zero)
Inversion.
|
boolean |
isNone() |
abstract boolean |
isSome() |
abstract <B> Either<A,B> |
left(B right)
Left projection of this option.
|
abstract List<A> |
list()
Transform an option into a list, either with a single element or an empty list.
|
<B> Option<B> |
map(Function<? super A,? extends B> f) |
abstract Monadics.ListMonadic<A> |
mlist()
Transform the option into a monadic list.
|
static <A> Option<A> |
none()
Create a new none.
|
static <A> Option<A> |
none(A example)
Create a none with the type of
example. |
static <A> Option<A> |
none(Class<A> clazz)
Create a none with the given type.
|
static <A> Function<A,Option<A>> |
option()
option(Object) as a function. |
static <A> Option<A> |
option(A a)
Wrap an arbitrary object into an option with
null being mapped to none. |
Option<A> |
orElse(Function0<Option<A>> none)
Lazy version of
orElse(Option). |
Option<A> |
orElse(Option<A> none)
If this is none return
none else this. |
<T extends Throwable> |
orError(Class<T> none)
Throw
none if none. |
<T extends Throwable> |
orError(Function0<T> none)
Throw exception returned by
none if none. |
<T extends Throwable> |
orError(T none)
Throw
none if none. |
abstract <B> Either<B,A> |
right(B left)
Right projection of this optio.
|
static <A> Option<A> |
some(A a)
Create a new some.
|
abstract com.entwinemedia.fn.data.Opt<A> |
toOpt() |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitforEach, iterator, spliteratorpublic abstract <B> B fold(Option.Match<A,B> visitor)
public <B> B fold(Function<A,B> some, Function0<B> none)
public abstract <B> Option<B> bind(Function<A,Option<B>> f)
m a -> (a -> m b) -> m b.public <B> Option<B> flatMap(Function<A,Option<B>> f)
Functions.bind(Function)public abstract boolean isSome()
public boolean isNone()
public <B> Option<B> andThen(Option<B> some)
some. Like bind(Function) but ignores the option's content.public <B> Option<B> andThenV(B some)
some. Like map(Function) but ignores the option's content.public <B> Option<B> andThen(Function0<Option<B>> some)
andThen(Option).public <B> Option<B> andThenV(Function0<B> some)
andThenV(Object).public <T extends Throwable> Option<A> orError(T none) throws T extends Throwable
none if none.T extends Throwablepublic <T extends Throwable> Option<A> orError(Class<T> none) throws T extends Throwable
none if none.T extends Throwablepublic <T extends Throwable> Option<A> orError(Function0<T> none) throws T extends Throwable
none if none.T extends Throwablepublic abstract A get()
public abstract A getOrElse(A none)
none otherwise.public abstract A getOrElse(Function0<A> none)
none otherwise.public abstract A getOrElseNull()
null values.public abstract Monadics.ListMonadic<A> mlist()
public abstract List<A> list()
public abstract <B> Either<A,B> left(B right)
some return the value in an
Either.left(Object) else return right in an Either.right(Object).public abstract <B> Either<B,A> right(B left)
some return the value in an
Either.left(Object) else return right in an Either.right(Object).public abstract com.entwinemedia.fn.data.Opt<A> toOpt()
public static <A> Option<A> some(A a)
public static <A> Option<A> none()
public static <A> Option<A> none(A example)
example. This saves some nasty typing, e.g.
Option.<String>none() vs. none("").
Please note that this constructor is only due to Java's insufficient type inference.
public static <A> Option<A> option(A a)
null being mapped to none.public static <A> Option<A> fromOpt(com.entwinemedia.fn.data.Opt<A> a)
Opt into an Option.public static <A> Function<A,Option<A>> option()
option(Object) as a function.@Deprecated public static <A> Function0<A> error(String message)
orError(Throwable) or orElse(Function0) instead since it saves the need for
creating new objects just for the sake of type soundness. Java unfortunately lacks a bottom type.getOrElse if it is an error being none.Copyright © 2009–2021 Opencast Project. All rights reserved.