public final class Either.RightProjection extends Object implements Either.Projection<R,L,L,R>
Modifier and Type | Method and Description |
---|---|
<X> Either<L,X> |
apply(Either<L,com.google.common.base.Function<R,X>> either)
Function application on this projection's value.
|
Either<L,R> |
either()
The either value underlying this projection.
|
boolean |
exists(com.google.common.base.Predicate<? super A> f)
Whether this is
is defined and
applying the predicate to the contained value returns true. |
<X> Option<Either<X,R>> |
filter(com.google.common.base.Predicate<? super R> f)
Returns
None if this projection has no value or if the given
predicate p does not hold for the value, otherwise, returns
a right in Some . |
<X,LL extends L> |
flatMap(com.google.common.base.Function<? super R,Either<LL,X>> f)
Binds the given function across this projection's value if it has one.
|
boolean |
forall(com.google.common.base.Predicate<? super A> f)
Returns
true if empty or the result of the
application of the given function to the value. |
void |
foreach(Effect<? super A> f)
Perform the given side-effect for each contained element.
|
R |
get()
Get the value if defined.
|
A |
getOrElse(com.google.common.base.Supplier<? extends A> a)
Get the value
if defined or call the supplier and
return its value if not. |
<X extends A> |
getOrElse(X x)
Get the value if defined, otherwise returns
other . |
A |
getOrError(com.google.common.base.Supplier<String> err)
Get the value or throws an error with the supplied message if not defined.
|
A |
getOrNull()
Get the value if defined or null if not.
|
<X extends Throwable> |
getOrThrow(com.google.common.base.Supplier<X> ifUndefined)
Get the value or throws the supplied throwable if not defined.
|
boolean |
isDefined() |
boolean |
isEmpty() |
Iterator<A> |
iterator() |
<X> Either<L,X> |
map(com.google.common.base.Function<? super R,X> f)
Map the given function across this projection's value if it has one.
|
R |
on(com.google.common.base.Function<? super L,? extends R> f)
The value of this projection or the result of the given function on the
opposing projection's value.
|
<X> Either<L,X> |
sequence(Either<L,X> e)
Anonymous bind through this projection.
|
Option<A> |
toOption()
Returns this projection's value in
Some if it exists,
otherwise None . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
either, toOption
exists, forall, getOrElse, getOrElse, getOrError, getOrNull, getOrThrow, isEmpty, iterator
foreach
public R get()
Maybe
public boolean isDefined()
public R on(com.google.common.base.Function<? super L,? extends R> f)
Either.Projection
public <X> Either<L,X> map(com.google.common.base.Function<? super R,X> f)
X
- the RHS typef
- The function to map across this projection.public <X,LL extends L> Either<L,X> flatMap(com.google.common.base.Function<? super R,Either<LL,X>> f)
X
- the RHS typeLL
- The existing LHS or a subtypef
- The function to bind across this projection.public <X> Either<L,X> sequence(Either<L,X> e)
X
- the RHS typee
- The value to bind with.public <X> Option<Either<X,R>> filter(com.google.common.base.Predicate<? super R> f)
None
if this projection has no value or if the given
predicate p
does not hold for the value, otherwise, returns
a right in Some
.X
- the LHS typef
- The predicate function to test on this projection's value.None
if this projection has no value or if the given
predicate p
does not hold for the value, otherwise, returns
a right in Some
.public <X> Either<L,X> apply(Either<L,com.google.common.base.Function<R,X>> either)
X
- the RHS typeeither
- The either of the function to apply on this projection's
value.public final Iterator<A> iterator()
iterator
in interface Maybe<A>
iterator
in interface Iterable<A>
if
defined
, or an empty one otherwise.public final Either<L,R> either()
Either.Projection
either
in interface Either.Projection<A,B,L,R>
public final boolean isEmpty()
public final Option<A> toOption()
Either.Projection
Some
if it exists,
otherwise None
.toOption
in interface Either.Projection<A,B,L,R>
Some
if it exists,
otherwise None
.public final boolean exists(com.google.common.base.Predicate<? super A> f)
Maybe
is defined
and
applying the predicate to the contained value returns true.public final A getOrNull()
Maybe
Although the use of null is discouraged, code written to use these must often interface with code that expects and returns nulls.
public final boolean forall(com.google.common.base.Predicate<? super A> f)
Maybe
true
if empty
or the result of the
application of the given function to the value.public final A getOrError(com.google.common.base.Supplier<String> err)
Maybe
Used when absolutely sure this is defined
.
getOrError
in interface Maybe<A>
err
- the message for the error.public <X extends Throwable> A getOrThrow(com.google.common.base.Supplier<X> ifUndefined) throws X extends Throwable
Maybe
Used when absolutely sure this is defined
.
getOrThrow
in interface Maybe<A>
X
- the type of the Throwable
that could be thrown.ifUndefined
- the supplier of the throwable.X
- the throwable the supplier creates if there is no value.X extends Throwable
public final A getOrElse(com.google.common.base.Supplier<? extends A> a)
Maybe
if defined
or call the supplier and
return its value if not.public final <X extends A> A getOrElse(X x)
Maybe
other
.getOrElse
in interface Maybe<A>
X
- the destination typex
- value to return if this is empty
is defined
, otherwise
returns other
public final void foreach(Effect<? super A> f)
Effect.Applicant
foreach
in interface Effect.Applicant<A>
f
- the input to use for performing the effect.Copyright © 2015 Atlassian. All rights reserved.