public class Either<L,R> extends Object
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
L |
error()
Returns the error object.
|
static <L,R> Either<L,R> |
error(L error) |
int |
hashCode() |
boolean |
isError() |
boolean |
isValue() |
<T> Either<L,T> |
map(Function<R,T> fn)
Applies a function to this value, if present.
|
String |
toString() |
static <L,R> Either<L,R> |
value(R value) |
R |
valueOrThrow()
If this Either represents a value, returns it.
|
public static <L,R> Either<L,R> error(L error)
public boolean isValue()
public boolean isError()
public L error()
IllegalStateException - if this instance is not an error@Nullable public R valueOrThrow()
Throwable, it is wrapped in a RuntimeException and thrown. If it is not a throwable,
a generic error is thrown containing the string representation of the error object.
To retrieve the error as-is, use isError() and error() instead.public <T> Either<L,T> map(Function<R,T> fn)
NullPointerException - if the mapping function returns nullCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.