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