| Modifier and Type | Method and Description |
|---|---|
Optional<Either<L,R>> |
filter(Predicate<R> predicate) |
void |
forEach(Consumer<? super R> consumer)
Executes the given side-effecting function if this is a Right
|
<X> Either<L,X> |
map(Function<R,X> mapper)
The given function is applied if this is a Right.
|
R |
orElse(R other) |
R |
orElseGet(Supplier<R> supplier) |
<X extends Exception> |
orElseThrow(Function<L,X> exceptionMapper) |
Either<L,R> |
peek(Consumer<? super R> consumer)
Executes the given side-effecting function if this is a Right and returns this Either
|
Optional<R> |
toOptional() |
public <X> Either<L,X> map(Function<R,X> mapper)
X - the resulting type of applying the functionmapper - the function to apply if this is a Rightpublic Optional<Either<L,R>> filter(Predicate<R> predicate)
predicate - predicatepublic Either<L,R> peek(Consumer<? super R> consumer)
consumer - consumerpublic void forEach(Consumer<? super R> consumer)
consumer - consumerpublic Optional<R> toOptional()
public R orElse(R other)
other - otherpublic R orElseGet(Supplier<R> supplier)
supplier - supplierpublic <X extends Exception> R orElseThrow(Function<L,X> exceptionMapper) throws X extends Exception
X - Type of the exception to be thrownexceptionMapper - The function which will return the exception to be thrownX - if this is a leftNullPointerException - if no value is present and exceptionSupplier is nullX extends ExceptionCopyright © 2014–2016. All rights reserved.