L - The type of the Left valueR - The type of the Right valuepublic class Either<L,R> extends Object
An Either is _not_ a pair. It does not contain two values. It only contains one value. However, the type of the value could either be the left type, or the right type.
A poor facsimile of the Either monad in Haskell that should make all Haskellers cry a little.
| Modifier and Type | Method and Description |
|---|---|
L |
getLeft()
Returns the Left value wrapped in this Either.
|
R |
getRight()
Returns the Right value wrapped in this Either.
|
boolean |
isLeft()
Returns whether or not this Either represents a Left value.
|
boolean |
isRight()
Returns whether or not this Either represents a Right value.
|
static <L,R> Either<L,R> |
left(L left)
Constructs an Either containing a left value.
|
static <L,R> Either<L,R> |
right(R right)
Constructs an Either containing a right value.
|
public static <L,R> Either<L,R> left(L left)
L - The type of the left valueR - The type of the right valueleft - The left value to store in the eitherpublic static <L,R> Either<L,R> right(R right)
L - The type of the left valueR - The type of the right valueright - The right value to store in the eitherpublic boolean isLeft()
public L getLeft()
UnsupportedOperationException - If this Either wraps a Right value insteadpublic boolean isRight()
public R getRight()
UnsupportedOperationException - If this Either wraps a Left value insteadCopyright © 2016–2018 Yahoo! Inc.. All rights reserved.