| java.lang.Object | |
| ↳ | com.atlassian.plugin.util.Either<L, R> |
A class that acts as a container for a value of one of two types. An Either will be either Either.Left Left or Either.Right Right.
Checking which type an Either is can be done by calling the @isLeft() and isRight() methods.
Eithers can be used to express a success or failure case. By convention, Right is used to store the success value,
(you can use the play on words "right" == "correct" as a mnemonic) and Left is used to store failure values (such
as exceptions).
While this class is public and abstract it does not expose a constructor as only the concrete Left and Right
subclasses are meant to be used.
Eithers are immutable, but do not force immutability on contained objects; if the contained objects are mutable then
equals and hashcode methods should not be relied on.
Copied from Atlassian FAGE/FUGUE, to be retired when that is adopted.
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Creates an Either based on a boolean expression.
| |||||||||||
Applies the function to the wrapped value, applying ifLeft it this is a Left and ifRight if this is a Right.
| |||||||||||
Simplifies extracting a value or throwing a checked exception from an Either.
| |||||||||||
Extracts an object from an Either, regardless of the side in which it is stored, provided both sides contain the
same type.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Creates an Either based on a boolean expression. If predicate is true, a Right wil be returned containing the supplied right value; if it is false, a Left will be returned containing the supplied left value.
Applies the function to the wrapped value, applying ifLeft it this is a Left and ifRight if this is a Right.
| ifLeft | the function to apply if this is a Left |
|---|---|
| ifRight | the function to apply if this is a Right |
Simplifies extracting a value or throwing a checked exception from an Either.
| either | to extract from |
|---|
| the exception on the LHS | |
| Exception |
| left | the value to be stored, must not be null |
|---|
Extracts an object from an Either, regardless of the side in which it is stored, provided both sides contain the same type. This method will never return null.
| right | the value to be stored, must not be null |
|---|