Either
The Either type represents a value of one of two possible types (a disjoint union), referred to by left or right .
Factory methods Either#left(Object) and Either#right(Object) correspond to the two possible values.
API
interface Either<L, R> {
Either<L, R> left(L left)
Either<L, R> right(R right)
Optional<L> left()
Optional<R> right()
L leftIfAny()
R rightIfAny()
boolean isLeft()
boolean isRight()
Either<T, R> mapLeft(Function<L, T> leftMapper)
Either<L, T> mapRight(Function<R, T> rightMapper)
Either<X, Y> map(Function<L, X> leftMapper, Function<R, Y> rightMapper)
T fold(BiFunction<L, R, T> biMapper)
T fold(Function<L, T> leftMapper, Function<R, T> rightMapper)
void accept(Consumer<L> leftConsumer, Consumer<R> rightConsumer)
Stream<T> foldStream(Stream<Either<L, R>> inputStream, Function<L, T> leftMapper, Function<R, T> rightMapper) (1)
}
| 1 | foldStream(Stream, Function, Function)
Folds elements of a Stream of Either resulting in a new Stream of type T. The resulting stream is guaranteed to not contain |
Members
foldStream(Stream, Function, Function)
Folds elements of a Stream of Either resulting in a new Stream of type T. The resulting stream is guaranteed to not contain null elements, that is, if any of the mappers maps to null, the element is ignored.
Absence of the leftMapper results in LEFT elements being ignored and absence of the rightMapper results in RIGHT elements being ignored.