public class LeftProjection<L,R> extends Object implements Iterable<L>, Serializable
Either
.Modifier and Type | Method and Description |
---|---|
Option<T> |
asOption()
|
boolean |
exists(java.util.function.Predicate<L> predicate)
|
Option<Either<L,R>> |
filter(java.util.function.Predicate<L> predicate)
|
<T> Either<T,R> |
flatMap(java.util.function.Function<L,Left<T,R>> function)
|
boolean |
forAll(java.util.function.Predicate<L> predicate)
|
T |
get()
Returns the value of the Right/Left side in case the projection matches the side, else throw
NoSuchElementException . |
L |
getOrElse(java.util.function.Supplier<L> supplier)
Returns the value if this is a
Left 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<T,R> |
map(java.util.function.Function<L,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, iterator, spliterator
public boolean exists(java.util.function.Predicate<L> predicate)
predicate
- The predicate to applyLeft
and the predicate matches the valuepublic L getOrElse(java.util.function.Supplier<L> supplier)
Left
else the value provided by the supplier.supplier
- The supplierpublic Option<Either<L,R>> filter(java.util.function.Predicate<L> predicate)
Some
wrapping the Either
if it's a Left
and the value of the Left
matches the predicate, else None
.predicate
- The predicate to applypublic boolean forAll(java.util.function.Predicate<L> predicate)
predicate
- The predicate to applypublic <T> Either<T,R> map(java.util.function.Function<L,T> function)
Left
then a new Left
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 Left
function
- The functionpublic <T> Either<T,R> flatMap(java.util.function.Function<L,Left<T,R>> function)
Left
then a new Left
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 Left
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