| Modifier and Type | Class and Description |
|---|---|
static class |
Either.Instance<R2>
|
static class |
Either.Mu<R>
The witness type for
Either. |
| Modifier and Type | Method and Description |
|---|---|
<L2> (L2|R) |
flatMap((L) -> (L2|R) function)
Maps the left value, if it is present, to a new type in an
Either. |
abstract (L|R) |
ifLeft((? super L) -> void consumer)
Applies the given callback if the left value is present.
|
abstract (L|R) |
ifRight((? super R) -> void consumer)
Applies the given callback if the right value is present.
|
abstract Optional<L> |
left()
Gets the left value in an
Optional. |
static <L,R> (L|R) |
left(L value)
Constructs an
Either with the given left value. |
abstract <T> T |
map((? super L) -> ? extends T l,
(? super R) -> ? extends T r)
Maps either the left or the right value, whichever is present, to a common third type.
|
abstract <C,D> (C|D) |
mapBoth((? super L) -> ? extends C f1,
(? super R) -> ? extends D f2)
Maps either the left or the right value, whichever is present, to another type.
|
<T> (T|R) |
mapLeft((? super L) -> ? extends T l)
Maps the left value, if present, to another type.
|
<T> (L|T) |
mapRight((? super R) -> ? extends T l)
Maps the right value, if present, to another type.
|
L |
orThrow()
Returns the left value if it is present, or throws an exception if it is not.
|
abstract Optional<R> |
right()
Gets the right value in an
Optional. |
static <L,R> (L|R) |
right(R value)
Constructs an
Either with the given right value. |
(R|L) |
swap()
Swaps the value in this
Either, such that the left value becomes the right value and visa-versa. |
static <L,R> (L|R) |
unbox((L|R) box)
|
public static <L,R> (L|R) unbox((L|R) box)
L - The left type.R - The right type.box - The boxed either.public abstract <C,D> (C|D) mapBoth((? super L) -> ? extends C f1, (? super R) -> ? extends D f2)
C - The new left type.D - The new right type.f1 - A mapping function for the left type.f2 - A mapping function for the right type.Either containing the new left or right value.public abstract <T> T map((? super L) -> ? extends T l, (? super R) -> ? extends T r)
T - The common type to map to.l - A mapping function for the left type.r - A mapping function for the right type.public abstract (L|R) ifLeft((? super L) -> void consumer)
consumer - A callback to apply to the left value.public abstract (L|R) ifRight((? super R) -> void consumer)
consumer - A callback to apply to the right value.public <T> (T|R) mapLeft((? super L) -> ? extends T l)
T - The new left type.l - A mapping function for the left value.Either which may contain the mapped left value.public <T> (L|T) mapRight((? super R) -> ? extends T l)
T - The new right type.l - A mapping function for the right value.Either which may contain the mapped right value.public static <L,R> (L|R) left(L value)
Either with the given left value.L - The left type.R - The right type.value - The left value.Either containing the given value.public static <L,R> (L|R) right(R value)
Either with the given right value.L - The left type.R - The right type.value - The right value.Either containing the given value.public L orThrow()
Throwable, the thrown exception has that value as its cause.RuntimeException - If the left value is not present.public (R|L) swap()
Either, such that the left value becomes the right value and visa-versa.