Left or a
Right.
If the given Either is a Right and projected to a Left, the Left operations have no effect on the Right value.
If the given Either is a Left and projected to a Right, the Right operations have no effect on the Left value.
If a Left is projected to a Left or a Right is projected to a Right, the operations have an effect.
Example: A compute() function, which results either in an Integer value (in the case of success) or in an error message of type String (in the case of failure). By convention the success case is Right and the failure is Left.
Either<String,Integer> value = compute().right().map(i -> i * 2).toEither();
If the result of compute() is Right(1), the value is Right(2).| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| public static class | Either.
The type of the Left value of an Either. L, The type of the Right value of an Either. R>
Deprecated
Either is right-biased. Use A left projection of an Either.
swap() instead of projections.
|
| public static class | |
| public static class | Either.
The type of the Left value of an Either. L, The type of the Right value of an Either. R>
Deprecated
Either is right-biased. Use A right projection of an Either.
swap() instead of projections.
|
| Modifier and Type | Field and Description |
|---|---|
| public static final long |
| Modifier and Type | Method and Description |
|---|---|
| public default < The new left type of the resulting Either X, The new right type of the resulting Either Y> Either | |
| public boolean | equals(Object
An object o)Redeclares io. Clarifies that values have a proper equals() method implemented. |
| public default Option | |
| public default Either | Returns: anEither instanceA predicate predicate, Function<? super R, ? extends L> A function that turns a right value into a left value if the right value does not make it through the filter. zero)Filters this right-biased |
| public default < Component type of the mapped right value U> Either | |
| public default < type of the folded value U> U | |
| public R | Returns: the right valueRedeclares io. Gets the right value if this is a |
| public L | |
| public default R | Returns: the right value, if the underlying Either is a Right or else the alternative Right value provided byother by applying the Left value.a function which converts a Left value to an alternative Right value other)Gets the Right value or an alternate value, if the projected Either is a Left. |
| public default < a throwable type X extends Throwable> R | Returns: the right value, if the underlying Either is a Right or else throws the exception provided byexceptionFunction by applying the Left value.a function which creates an exception based on a Left value exceptionFunction)Gets the Right value or throws, if the projected Either is a Left. |
| public int | hashCode()
Redeclares io. Clarifies that values have a proper hashCode() method implemented. |
| public default boolean | Returns: falseImplements io. A right-biased |
| public default boolean | isEmpty()
Implements io. Checks, this |
| public default boolean | Returns: falseImplements io. A right-biased |
| public boolean | |
| public boolean | |
| public default boolean | Returns: trueImplements io. A right-biased |
| public default Iterator | |
| public static < Type of left value. L, Type of right value. R> Either | |
| public default Either. | |
| public default < Component type of the mapped right value U> Either | Returns: a mappedMonadA mapper mapper)Implements io. Maps the value of this Either if it is a Right, performs no operation if this is a Left. |
| public default < Component type of the mapped right value U> Either | |
| public static < Type of left value. L, Type of right value. R> Either | |
| public default Either | |
| public default Either | |
| public default void | |
| public default Either | peek(Consumer<? super R>
The action that will be performed on the element(s). action)Implements io. Performs the given |
| public default Either | |
| public static < Type of left value. L, Type of right value. R> Either | |
| public default Either. | |
| public static < closure of all left types of the given L, Eithersclosure of all right types of the given R> EitherEithers | |
| public static < closure of all left types of the given L, Eithersclosure of all right types of the given R> EitherEithers | sequenceRight(Iterable<? extends Either<? extends L, ? extends R>>
An eithers)Iterable of EithersReduces many |
| public default Either | Returns: a newEitherConverts a |
| public String | toString()
Redeclares io. Clarifies that values have a proper toString() method implemented. |
| public default Validation | Returns: Validation.valid(get()) if this is right, otherwise Validation.invalid(getLeft()).Returns this as |
| public static < The mapped left value type. L, The mapped right value type. R, The type of the given values. T> Either | |
| public static < The mapped left value type. L, The mapped right value type. R, The type of the given values. T> Either | traverseRight(Iterable<? extends T>
An values, Function<? super T, ? extends Either<? extends L, ? extends R>> Iterable of values.A mapper of values to Eithers mapper)Maps the values of an iterable to a sequence of mapped values into a single |