public abstract class Either<LEFT,RIGHT> extends Object
Modifier and Type | Method and Description |
---|---|
abstract LEFT |
getLeft()
Returns the left value.
|
abstract Optional<LEFT> |
getLeftOption()
Left value or empty otherwise.
|
abstract RIGHT |
getRight()
Returns the right value.
|
abstract Optional<RIGHT> |
getRightOption()
Right value or empty otherwise.
|
abstract boolean |
isLeft()
Returns whether the instance holds a left value.
|
abstract boolean |
isRight()
Returns whether the instance holds a right value.
|
static <LEFT,RIGHT> |
ofLeft(LEFT value) |
static <LEFT,RIGHT> |
ofRight(RIGHT value) |
abstract <X> X |
transform(java.util.function.Function<LEFT,X> lhsTransformer,
java.util.function.Function<RIGHT,X> rhsTransformer)
Apply a function based on whether the instance holds a left or right value.
|
public abstract boolean isLeft()
public abstract boolean isRight()
public abstract LEFT getLeft()
IllegalStateException
- if this instance does not hold a left value.public abstract RIGHT getRight()
IllegalStateException
- if this instance does not hold a right value.public abstract <X> X transform(java.util.function.Function<LEFT,X> lhsTransformer, java.util.function.Function<RIGHT,X> rhsTransformer)
public static <LEFT,RIGHT> Either<LEFT,RIGHT> ofLeft(LEFT value)
public static <LEFT,RIGHT> Either<LEFT,RIGHT> ofRight(RIGHT value)