public class RightProjection<L,R> extends Object implements Serializable
Either
.Modifier and Type | Method and Description |
---|---|
Option<T> |
asOption()
|
boolean |
exists(java.util.function.Predicate<R> predicate)
|
Option<Either<L,R>> |
filter(java.util.function.Predicate<R> predicate)
|
<T> Either<L,T> |
flatMap(java.util.function.Function<R,Right<L,T>> function)
|
boolean |
forAll(java.util.function.Predicate<R> predicate)
|
T |
get()
Returns the value of the Right/Left side in case the projection matches the side, else throw
NoSuchElementException . |
R |
getOrElse(java.util.function.Supplier<R> supplier)
Returns the value if this is a
Right else the value provided by the supplier. |
Iterator<T> |
iterator()
Returns the iterator of the Right/Left side in case the projection matches the side.
|
<T> Either<L,T> |
map(java.util.function.Function<R,T> function)
|
T |
orNull()
Returns the value of this projection if it is of the correct type else
null . |
java.util.stream.Stream<T> |
stream()
Returns the stream of the Right/Left side in case the projection matches the side.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public boolean exists(java.util.function.Predicate<R> predicate)
predicate
- The predicate to applyRight
and the predicate matches the valuepublic R getOrElse(java.util.function.Supplier<R> supplier)
Right
else the value provided by the supplier.supplier
- The supplierpublic Option<Either<L,R>> filter(java.util.function.Predicate<R> predicate)
Some
wrapping the Either
if it's a Right
and the value of the Right
matches the predicate, else None
.predicate
- The predicate to applypublic boolean forAll(java.util.function.Predicate<R> predicate)
predicate
- The predicate to applypublic <T> Either<L,T> map(java.util.function.Function<R,T> function)
Right
then a new Right
is returned containing the value from the original Right
mapped via the
provided function, else the contained Either is returned as is.T
- The type to return as the new Right
function
- The functionpublic <T> Either<L,T> flatMap(java.util.function.Function<R,Right<L,T>> function)
Right
then a new Right
is returned containing the value from the original Right
mapped via the
provided function, else the contained Either is returned as is.T
- The type to return as the new Right
function
- The functionpublic Option<T> asOption()
Some
side in case the projection matches the side, else None
. RightProjection
with a Right
LeftProjection
with a Left
. Some
containing the value of the Left
/Right
. None
.public T get()
NoSuchElementException
. RightProjection
with a Right
LeftProjection
with a Left
. Left
/Right
. NoSuchElementException
.public Iterator<T> iterator()
RightProjection
with a Right
LeftProjection
with a Left
. Left
/Right
. public java.util.stream.Stream<T> stream()
RightProjection
with a Right
LeftProjection
with a Left
. Left
/Right
. public T orNull()
null
. RightProjection
with a Right
LeftProjection
with a Left
. Left
/Right
. null
. getOrElse(Supplier)
where the supplier returns null
. getOrElse(() -> null)
null
Copyright © 2015, Peter Nerg Apache License v2.0