Modifier and Type | Method and Description |
---|---|
<X> Either<X,B> |
apply(Either<F<A,X>,B> e)
Function application on this projection's value.
|
<X> Either<X,B> |
bind(F<A,Either<X,B>> f)
Binds the given function across this projection's value if it has one.
|
Either<A,B> |
either()
The either value underlying this projection.
|
boolean |
exists(F<A,java.lang.Boolean> f)
Returns
false if no value or returns the result of the application of the given
function to the value. |
<X> Option<Either<A,X>> |
filter(F<A,java.lang.Boolean> 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 . |
boolean |
forall(F<A,java.lang.Boolean> f)
Returns
true if no value or returns the result of the application of the given
function to the value. |
Unit |
foreach(F<A,Unit> f)
Execute a side-effect on this projection's value if it has one.
|
void |
foreachDoEffect(Effect1<A> f)
Execute a side-effect on this projection's value if it has one.
|
java.util.Iterator<A> |
iterator()
Returns an iterator for this projection.
|
<X> Either<X,B> |
map(F<A,X> f)
Map the given function across this projection's value if it has one.
|
A |
on(F<B,A> f)
The value of this projection or the result of the given function on the opposing projection's
value.
|
A |
orValue(A a)
The value of this projection or the given argument.
|
A |
orValue(P1<A> a)
The value of this projection or the given argument.
|
<X> Either<X,B> |
sequence(Either<X,B> e)
Anonymous bind through this projection.
|
Array<A> |
toArray()
Returns a single element array if this projection has a value, otherwise an empty array.
|
java.util.Collection<A> |
toCollection()
Projects an immutable collection of this projection.
|
List<A> |
toList()
Returns a single element list if this projection has a value, otherwise an empty list.
|
Option<A> |
toOption()
Returns this projection's value in
Some if it exists, otherwise
None . |
Stream<A> |
toStream()
Returns a single element stream if this projection has a value, otherwise an empty stream.
|
A |
value()
The value of this projection or fails with a specialised error message.
|
A |
valueE(P1<java.lang.String> err)
Returns the value of this projection or fails with the given error message.
|
A |
valueE(java.lang.String err)
Returns the value of this projection or fails with the given error message.
|
public java.util.Iterator<A> iterator()
for
-each loop.iterator
in interface java.lang.Iterable<A>
public Either<A,B> either()
public A valueE(P1<java.lang.String> err)
err
- The error message to fail with.public A valueE(java.lang.String err)
err
- The error message to fail with.public A value()
public A orValue(P1<A> a)
a
- The value to return if this projection has no value.public A orValue(A a)
a
- The value to return if this projection has no value.public A on(F<B,A> f)
f
- The function to execute if this projection has no value.public Unit foreach(F<A,Unit> f)
f
- The side-effect to execute.public void foreachDoEffect(Effect1<A> f)
f
- The side-effect to execute.public <X> Either<X,B> map(F<A,X> f)
f
- The function to map across this projection.public <X> Either<X,B> bind(F<A,Either<X,B>> f)
f
- The function to bind across this projection.public <X> Either<X,B> sequence(Either<X,B> e)
e
- The value to bind with.public <X> Option<Either<A,X>> filter(F<A,java.lang.Boolean> 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
.f
- 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<X,B> apply(Either<F<A,X>,B> e)
e
- The either of the function to apply on this projection's value.public boolean forall(F<A,java.lang.Boolean> f)
true
if no value or returns the result of the application of the given
function to the value.f
- The predicate function to test on this projection's value.true
if no value or returns the result of the application of the given
function to the value.public boolean exists(F<A,java.lang.Boolean> f)
false
if no value or returns the result of the application of the given
function to the value.f
- The predicate function to test on this projection's value.false
if no value or returns the result of the application of the given
function to the value.public List<A> toList()
public Option<A> toOption()
Some
if it exists, otherwise
None
.Some
if it exists, otherwise
None
.public Array<A> toArray()
public Stream<A> toStream()
public java.util.Collection<A> toCollection()