public abstract class Either<X,Y>
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
abstract <S> S |
flatMap(java.util.function.Function<X,S> mapLeft,
java.util.function.Function<Y,S> mapRight)
Applies the respective mapper to obtain an object of type
S. |
abstract void |
ifLeft(java.util.function.Consumer<X> consumer)
Applies the given consumer if this either is a left value.
|
abstract void |
ifRight(java.util.function.Consumer<Y> consumer)
Applies the given consumer if this either is a right value.
|
abstract boolean |
isLeft()
Whether the either is a left value or not.
|
abstract boolean |
isRight()
Whether the either is a right value or not.
|
abstract X |
left()
Will take this either as a left value.
|
static <X,Y> Either<X,Y> |
left(X object)
Creates a left either instance with the given value.
|
abstract X |
leftOrElse(X other)
Will take this either as a left value.
|
abstract X |
leftOrElseGet(java.util.function.Supplier<X> other)
Will take this either as a left value.
|
X |
leftOrNull()
Will take this either as a left value.
|
<R,S> Either<R,S> |
map(java.util.function.Function<X,R> mapLeft,
java.util.function.Function<Y,S> mapRight)
Applies the respective mapper given whether this either is a left or right value.
|
abstract <S> Either<S,Y> |
mapLeft(java.util.function.Function<X,S> mapper)
Applies the given mapper if this either is a left value.
|
abstract <S> Either<X,S> |
mapRight(java.util.function.Function<Y,S> mapper)
Applies the given mapper if this either is a right value.
|
abstract Y |
right()
Will take this either as a right value.
|
static <X,Y> Either<X,Y> |
right(Y object)
Creates a right either instance with the given value.
|
abstract Y |
rightOrElse(Y other)
Will take this either as a right value.
|
abstract Y |
rightOrElseGet(java.util.function.Supplier<Y> other)
Will take this either as a right value.
|
Y |
rightOrNull()
Will take this either as a right value.
|
public static <X,Y> Either<X,Y> left(X object)
public static <X,Y> Either<X,Y> right(Y object)
public abstract boolean isLeft()
public abstract boolean isRight()
public abstract X left()
java.util.NoSuchElementException - if the either is a right valuepublic abstract Y right()
java.util.NoSuchElementException - if the either is a left valuepublic abstract X leftOrElse(X other)
public abstract Y rightOrElse(Y other)
public abstract X leftOrElseGet(java.util.function.Supplier<X> other)
public abstract Y rightOrElseGet(java.util.function.Supplier<Y> other)
public X leftOrNull()
null will be returned.public Y rightOrNull()
null will be returned.public abstract <S> Either<S,Y> mapLeft(java.util.function.Function<X,S> mapper)
public abstract <S> Either<X,S> mapRight(java.util.function.Function<Y,S> mapper)
public <R,S> Either<R,S> map(java.util.function.Function<X,R> mapLeft, java.util.function.Function<Y,S> mapRight)
public abstract <S> S flatMap(java.util.function.Function<X,S> mapLeft, java.util.function.Function<Y,S> mapRight)
S.public abstract void ifLeft(java.util.function.Consumer<X> consumer)
public abstract void ifRight(java.util.function.Consumer<Y> consumer)