public static class Either.Left<L,R> extends java.lang.Object implements Either<L,R>
Either.Left<L,R>, Either.Right<L,RT>
Constructor and Description |
---|
Left() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
Option<R> |
filter(java.util.function.Predicate<? super R> test)
Keep only elements for which the supplied predicates hold
e.g.
|
Either<L,R> |
filter(java.util.function.Predicate<? super R> test,
java.util.function.Function<? super R,? extends L> rightToLeft) |
<RT1> Either<L,RT1> |
flatMap(java.util.function.Function<? super R,? extends Either<? extends L,? extends RT1>> mapper) |
<LT1> Either<LT1,R> |
flatMapLeft(java.util.function.Function<? super L,? extends Either<LT1,R>> mapper)
Perform a flatMap operation on the Left type
|
Either<L,R> |
flatMapLeftToRight(java.util.function.Function<? super L,? extends Either<L,R>> fn)
A flatMap operation that keeps the Left and Right types the same
|
<R2> R2 |
fold(java.util.function.Function<? super L,? extends R2> fn1,
java.util.function.Function<? super R,? extends R2> fn2)
Visitor pattern for this Ior.
|
<R2> R2 |
fold(java.util.function.Function<? super R,? extends R2> present,
java.util.function.Supplier<? extends R2> absent) |
Option<R> |
get() |
Option<L> |
getLeft() |
int |
hashCode() |
boolean |
isLeft() |
boolean |
isRight() |
L |
leftOrElse(L alt) |
ReactiveSeq<L> |
leftToStream() |
<R2> Either<L,R2> |
map(java.util.function.Function<? super R,? extends R2> fn)
Transform this functor using the supplied transformation function
|
<R2> Either<R2,R> |
mapLeft(java.util.function.Function<? super L,? extends R2> fn)
Always transform the Left type of this Either if it is present using the provided transformation function
|
Either<L,R> |
mapLeftToRight(java.util.function.Function<? super L,? extends R> fn)
If this Either contains the Left type, transform it's value so that it contains the Right type
|
java.lang.String |
mkString()
Returns the class name and the name of the subclass, if there is any value, the value is showed between square brackets.
|
Either<L,R> |
peek(java.util.function.Consumer<? super R> action)
Peek at the current value of this Transformable, without transforming it
|
Either<L,R> |
peekLeft(java.util.function.Consumer<? super L> action)
Peek at the Left type value if present
|
Either<L,R> |
recover(R value) |
Either<L,R> |
recover(java.util.function.Supplier<? extends R> value) |
Either<L,R> |
recoverWith(java.util.function.Supplier<? extends Either<L,R>> fn) |
Either<R,L> |
swap()
Swap types so operations directly affect the current (pre-swap) Left type
|
Ior<L,R> |
toIor() |
Maybe<R> |
toMaybe() |
java.util.Optional<R> |
toOptional() |
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
accumulateLeft, accumulateLeft, accumulateLeft, accumulateRight, accumulateRight, accumulateRight, applyAny, arity, bimap, bipeek, combine, combineToLazySeq, combineToVector, consumeAny, filterNot, foldAny, forEach2, forEach3, forEach4, fromIterable, fromPublisher, isPresent, lazySeq, left, narrowK, narrowK2, nest, nestedEval, notNull, ofType, right, sequence, sequenceLeft, sequenceRight, tailRec, toEither, toTrampoline, traverse, unit, visitAny, visitAny, widen, zip, zip
orElseUse, orElseUse
public Either<L,R> recoverWith(java.util.function.Supplier<? extends Either<L,R>> fn)
recoverWith
in interface Either<L,R>
public boolean isLeft()
public boolean isRight()
public Either<L,R> mapLeftToRight(java.util.function.Function<? super L,? extends R> fn)
Either
mapLeftToRight
in interface Either<L,R>
fn
- Function to transform left type to rightpublic <R2> Either<R2,R> mapLeft(java.util.function.Function<? super L,? extends R2> fn)
Either
public <R2> Either<L,R2> map(java.util.function.Function<? super R,? extends R2> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
public Either<L,R> peekLeft(java.util.function.Consumer<? super L> action)
Either
public Either<L,R> peek(java.util.function.Consumer<? super R> action)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
public Option<R> filter(java.util.function.Predicate<? super R> test)
Filters
of(1,2,3).filter(i->i>2);
//[3]
public Either<L,R> filter(java.util.function.Predicate<? super R> test, java.util.function.Function<? super R,? extends L> rightToLeft)
public Either<R,L> swap()
Either
Either.left("hello")
.map(v->v+" world")
//Either.seconary["hello"]
Either.left("hello")
.swap()
.map(v->v+" world")
.swap()
//Either.seconary["hello world"]
public ReactiveSeq<L> leftToStream()
leftToStream
in interface Either<L,R>
public <RT1> Either<L,RT1> flatMap(java.util.function.Function<? super R,? extends Either<? extends L,? extends RT1>> mapper)
public <LT1> Either<LT1,R> flatMapLeft(java.util.function.Function<? super L,? extends Either<LT1,R>> mapper)
Either
flatMapLeft
in interface Either<L,R>
mapper
- Flattening transformation functionpublic Either<L,R> flatMapLeftToRight(java.util.function.Function<? super L,? extends Either<L,R>> fn)
Either
flatMapLeftToRight
in interface Either<L,R>
fn
- Transformation functionpublic java.util.Optional<R> toOptional()
toOptional
in interface Value<R>
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String mkString()
Value
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public <R2> R2 fold(java.util.function.Function<? super L,? extends R2> fn1, java.util.function.Function<? super R,? extends R2> fn2)
Either
Either.right(10)
.visit(left->"no", right->"yes")
//Either["yes"]
Either.left(90)
.visit(left->"no", right->"yes")
//Either["no"]