Either.Left, Either.Rightpublic abstract class Either<A,B>
extends java.lang.Object
| Modifier and Type | Class | Description |
|---|---|---|
static class |
Either.Left<A,B> |
|
static class |
Either.Right<A,B> |
| Modifier and Type | Method | Description |
|---|---|---|
abstract Either<B,A> |
flip() |
Flip an Either<A,B> to a Either<B,A>.
|
abstract A |
getLeft() |
|
abstract B |
getRight() |
|
boolean |
isLeft() |
|
boolean |
isRight() |
|
static <A,B> Either<A,B> |
left(A left) |
Factory method for constructing lefts.
|
abstract <X,Y> Either<X,Y> |
map(java.util.function.Function<A,X> leftFunction,
java.util.function.Function<B,Y> rightFunction) |
Map this Either<A,B> to a new Either<X,Y>.
|
abstract <T> T |
reduce(java.util.function.Function<A,T> leftFunction,
java.util.function.Function<B,T> rightFunction) |
Reduce an Either<A,B> to a single value type T.
|
static <A,B> Either<A,B> |
right(B right) |
Factory method for constructing rights.
|
abstract void |
use(java.util.function.Consumer<A> leftConsumer,
java.util.function.Consumer<B> rightConsumer) |
Pass the value of this either to a consumer.
|
public static <A,B> Either<A,B> left(A left)
A - the left typeB - the right typeleft - the left valuepublic static <A,B> Either<A,B> right(B right)
A - the left typeB - the right typeright - the right valuepublic final boolean isLeft()
public final boolean isRight()
public abstract A getLeft()
java.lang.UnsupportedOperationException - if the receiver is rightpublic abstract B getRight()
java.lang.UnsupportedOperationException - if the receiver is leftpublic abstract void use(java.util.function.Consumer<A> leftConsumer, java.util.function.Consumer<B> rightConsumer)
leftConsumer - the consumer for leftsrightConsumer - the consumer for rightspublic abstract <X,Y> Either<X,Y> map(java.util.function.Function<A,X> leftFunction, java.util.function.Function<B,Y> rightFunction)
X - the new left typeY - the new right typeleftFunction - function to convert A to XrightFunction - function to convert B to Ypublic abstract <T> T reduce(java.util.function.Function<A,T> leftFunction, java.util.function.Function<B,T> rightFunction)
T - the result typeleftFunction - function to convert A to TrightFunction - function to convert B to TCopyright © 2018. All rights reserved.