public static class Either.Right<L,RT> extends java.lang.Object implements Either<L,RT>
Either.Left<L,R>, Either.Right<L,RT>
Constructor and Description |
---|
Right() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
Option<RT> |
filter(java.util.function.Predicate<? super RT> test)
Keep only elements for which the supplied predicates hold
e.g.
|
Either<L,RT> |
filter(java.util.function.Predicate<? super RT> test,
java.util.function.Function<? super RT,? extends L> rightToLeft) |
<RT1> Either<L,RT1> |
flatMap(java.util.function.Function<? super RT,? extends Either<? extends L,? extends RT1>> mapper) |
<LT1> Either<LT1,RT> |
flatMapLeft(java.util.function.Function<? super L,? extends Either<LT1,RT>> mapper)
Perform a flatMap operation on the Left type
|
Either<L,RT> |
flatMapLeftToRight(java.util.function.Function<? super L,? extends Either<L,RT>> fn)
A flatMap operation that keeps the Left and Right types the same
|
<R> R |
fold(java.util.function.Function<? super L,? extends R> left,
java.util.function.Function<? super RT,? extends R> right)
Visitor pattern for this Ior.
|
<R> R |
fold(java.util.function.Function<? super RT,? extends R> present,
java.util.function.Supplier<? extends R> absent) |
Option<RT> |
get() |
Option<L> |
getLeft() |
int |
hashCode() |
boolean |
isLeft() |
boolean |
isRight() |
L |
leftOrElse(L alt) |
ReactiveSeq<L> |
leftToStream() |
<R> Either<L,R> |
map(java.util.function.Function<? super RT,? extends R> fn)
Transform this functor using the supplied transformation function
|
<R> Either<R,RT> |
mapLeft(java.util.function.Function<? super L,? extends R> fn)
Always transform the Left type of this Either if it is present using the provided transformation function
|
Either<L,RT> |
mapLeftToRight(java.util.function.Function<? super L,? extends RT> 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,RT> |
peek(java.util.function.Consumer<? super RT> action)
Peek at the current value of this Transformable, without transforming it
|
Either<L,RT> |
peekLeft(java.util.function.Consumer<? super L> action)
Peek at the Left type value if present
|
Either<L,RT> |
recover(RT value) |
Either<L,RT> |
recover(java.util.function.Supplier<? extends RT> value) |
Either<L,RT> |
recoverWith(java.util.function.Supplier<? extends Either<L,RT>> fn) |
Either<RT,L> |
swap()
Swap types so operations directly affect the current (pre-swap) Left type
|
Ior<L,RT> |
toIor() |
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, 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
asSupplier, collect, fold, forEach, generate, iterate, iterator, newSubscriber, nonEmptyList, nonEmptyListGet, orElse, orElseGet, print, print, printErr, printOut, stream, subscribe, toLazyEither, toLeft, toMaybe, toOption, toOptional, toRight, toTry, toTry, toTry, transform
public Either<L,RT> recoverWith(java.util.function.Supplier<? extends Either<L,RT>> fn)
recoverWith
in interface Either<L,RT>
public Either<L,RT> mapLeftToRight(java.util.function.Function<? super L,? extends RT> fn)
Either
mapLeftToRight
in interface Either<L,RT>
fn
- Function to transform left type to rightpublic <R> Either<R,RT> mapLeft(java.util.function.Function<? super L,? extends R> fn)
Either
public <R> Either<L,R> map(java.util.function.Function<? super RT,? extends R> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
public Either<L,RT> peekLeft(java.util.function.Consumer<? super L> action)
Either
public Either<L,RT> peek(java.util.function.Consumer<? super RT> action)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
public Option<RT> filter(java.util.function.Predicate<? super RT> test)
Filters
of(1,2,3).filter(i->i>2);
//[3]
public Either<L,RT> filter(java.util.function.Predicate<? super RT> test, java.util.function.Function<? super RT,? extends L> rightToLeft)
public Either<RT,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,RT>
public <RT1> Either<L,RT1> flatMap(java.util.function.Function<? super RT,? extends Either<? extends L,? extends RT1>> mapper)
public <LT1> Either<LT1,RT> flatMapLeft(java.util.function.Function<? super L,? extends Either<LT1,RT>> mapper)
Either
flatMapLeft
in interface Either<L,RT>
mapper
- Flattening transformation functionpublic Either<L,RT> flatMapLeftToRight(java.util.function.Function<? super L,? extends Either<L,RT>> fn)
Either
flatMapLeftToRight
in interface Either<L,RT>
fn
- Transformation functionpublic boolean isRight()
public boolean isLeft()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String mkString()
Value
public <R> R fold(java.util.function.Function<? super L,? extends R> left, java.util.function.Function<? super RT,? extends R> right)
Either
Either.right(10)
.visit(left->"no", right->"yes")
//Either["yes"]
Either.left(90)
.visit(left->"no", right->"yes")
//Either["no"]
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object