L
- the type of the left valueR
- the type of the right valuepublic final class Either<L,R> extends Object
Modifier and Type | Method and Description |
---|---|
void |
apply(Consumer<? super L> leftFunc,
Consumer<? super R> rightFunc)
Receives a
Consumer functions for both, the left and right value and applies the one over the value that is present. |
void |
applyLeft(Consumer<? super L> consumer) |
void |
applyRight(Consumer<? super R> consumer) |
L |
getLeft() |
R |
getRight() |
Optional<Object> |
getValue() |
boolean |
isLeft() |
boolean |
isRight() |
static <L,R> Either<L,R> |
left(L value)
Creates an
Either with a left value. |
<T> Either<T,R> |
mapLeft(Function<? super L,? extends T> func)
Allows to execute a function over the left value if it is present
|
<T> Either<L,T> |
mapRight(Function<? super R,? extends T> func)
Allows to execute a function over the right value if it is present
|
<T> T |
reduce(Function<? super L,? extends T> leftFunc,
Function<? super R,? extends T> rightFunc)
Allows to reduce to a single value using left and right functions with the same return type.
|
static <L,R> Either<L,R> |
right(R value)
Creates an
Either with a right value. |
String |
toString() |
public static <L,R> Either<L,R> left(L value)
Either
with a left value.L
- the left value typeR
- the right value typevalue
- the left valueEither instance
public static <L,R> Either<L,R> right(R value)
Either
with a right value.L
- the left value typeR
- the right value typevalue
- the right valueEither instance
public <T> T reduce(Function<? super L,? extends T> leftFunc, Function<? super R,? extends T> rightFunc)
T
- the return type of the function.leftFunc
- the function to apply to the left valuerightFunc
- the function to apply to the left valuepublic <T> Either<T,R> mapLeft(Function<? super L,? extends T> func)
T
- the return type of the function.func
- the function to apply to the left valueEither
created from the result of applying the function.public <T> Either<L,T> mapRight(Function<? super R,? extends T> func)
T
- the return type of the function.func
- the function to apply to the right valueEither
created from the result of applying the function.public void apply(Consumer<? super L> leftFunc, Consumer<? super R> rightFunc)
Consumer
functions for both, the left and right value and applies the one over the value that is present.leftFunc
- the function to apply to the left valuerightFunc
- the function to apply to the right valuepublic boolean isLeft()
public boolean isRight()
public L getLeft()
public R getRight()
Copyright © 2018. All rights reserved.