public static final class Either.Lazy<ST,PT> extends java.lang.Object implements Either<ST,PT>
Either.CompletableEither<ORG,RT>, Either.Lazy<ST,PT>, Either.Left<ST,PT>, Either.Right<ST,PT>
Xor.Instances, Xor.Primary<ST,PT>, Xor.Secondary<ST,PT>
Value.ValueImpl<T>
Convertable.SupplierToConvertable<T>
Fn0.FunctionalOperations<R>, Fn0.SupplierKind<R>
Constructor and Description |
---|
Lazy() |
Modifier and Type | Method and Description |
---|---|
<T2,R> Either<ST,R> |
combine(Value<? extends T2> app,
java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
Lazily combine this ApplicativeFunctor with the supplied value via the supplied BiFunction
Example
|
boolean |
equals(java.lang.Object obj) |
Either<ST,PT> |
filter(java.util.function.Predicate<? super PT> test)
Keep only elements for which the supplied predicates hold
e.g.
|
<RT1> Either<ST,RT1> |
flatMap(java.util.function.Function<? super PT,? extends MonadicValue<? extends RT1>> mapper)
A flattening transformation operation (@see
Optional.flatMap(Function) |
PT |
get() |
int |
hashCode() |
boolean |
isLeft() |
boolean |
isRight() |
<R> Either<ST,R> |
map(java.util.function.Function<? super PT,? extends R> mapper)
Transform this functor using the supplied transformation function
|
Eval<Xor<ST,PT>> |
nestedEval() |
Either<ST,PT> |
peek(java.util.function.Consumer<? super PT> action)
Peek at the current value of this Transformable, without transforming it
|
void |
peek(java.util.function.Consumer<? super ST> stAction,
java.util.function.Consumer<? super PT> ptAction) |
Either<ST,PT> |
resolve() |
<LT1> Either<LT1,PT> |
secondaryFlatMap(java.util.function.Function<? super ST,? extends Xor<LT1,PT>> mapper)
Perform a flatMap operation on the Left type
|
ST |
secondaryGet() |
<R> Either<R,PT> |
secondaryMap(java.util.function.Function<? super ST,? extends R> fn)
Always map the Left type of this Either if it is present using the provided transformation function
|
Either<ST,PT> |
secondaryPeek(java.util.function.Consumer<? super ST> action)
Peek at the Left type value if present
|
java.util.Optional<ST> |
secondaryToOptional() |
Either<ST,PT> |
secondaryToPrimayFlatMap(java.util.function.Function<? super ST,? extends Xor<ST,PT>> fn)
A flatMap operation that keeps the Left and Right types the same
|
Either<ST,PT> |
secondaryToPrimayMap(java.util.function.Function<? super ST,? extends PT> fn)
If this Either contains the Left type, map it's value so that it contains the Right type
|
ReactiveSeq<ST> |
secondaryToStream() |
Value<ST> |
secondaryValue() |
void |
subscribe(org.reactivestreams.Subscriber<? super PT> sub) |
Either<PT,ST> |
swap()
Swap types so operations directly affect the current (pre-swap) Left type
|
Trampoline<Either<ST,PT>> |
toEitherTrampoline() |
Ior<ST,PT> |
toIor()
Return an Ior that can be this object or a Ior.primary or Ior.secondary
|
java.lang.String |
toString() |
<R> R |
visit(java.util.function.Function<? super ST,? extends R> secondary,
java.util.function.Function<? super PT,? extends R> primary)
Visitor pattern for this Ior.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
accumulate, anyMEither, applyAny, async, bicast, bimap, bipeek, bitrampoline, cast, coflatMap, combine, combine, combineEager, combineToList, combineToList, consumeAny, either, filterNot, flatMapI, flatMapP, flatMapS, forEach2, forEach2, forEach3, forEach3, forEach4, forEach4, fromFuture, fromIterable, fromLazy, fromMonadicValue, fromPublisher, fromXor, isPresent, isPrimary, isSecondary, left, leftEval, list, mapBoth, narrow, nest, notNull, ofType, retry, retry, right, rightEval, sequenceLeft, sequenceRight, tailRec, toOptional, toTrampoline, toTrampoline, toTrampoline, toXor, toXor, trampoline, traverseLeft, traverseRight, unit, visitAny, visitAny, zip, zip, zip, zip3, zip3, zip4, zip4, zipP, zipP, zipS, zipS, zipWith, zipWithP, zipWithS
accumulatePrimary, accumulatePrimary, accumulatePrimary, accumulateSecondary, accumulateSecondary, accumulateSecondary, allTypeclasses, anyM, applyAny, arity, consumeAny, coproduct, kindCokleisli, kindKleisli, liftM, mapM, narrowK, narrowK2, nested, primary, product, secondary, sequencePrimary, sequenceSecondary, tailRec, visitAny, visitAny, widen
apply, generate, iterate, iterator, mkString, newSubscriber, of, stream, test, toEither, toEval, toEvalAlways, toEvalLater, toEvalNow, toLeft, toMaybe, toMaybeEager, toRight, toTry, toTry, toTry
endsWith, endsWithIterable, findAny, findFirst, firstValue, foldLeft, foldLeft, foldLeft, foldLeft, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, join, join, join, mapReduce, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce, schedule, scheduleFixedDelay, scheduleFixedRate, single, single, singleUnsafe, startsWith, startsWithIterable, takeOne, xMatch
collect, fromSupplier, orElse, orElseGet, orElseThrow, toCompletableFuture, toCompletableFutureAsync, toFuture, toFutureAsync, toStream, visit
public Trampoline<Either<ST,PT>> toEitherTrampoline()
toEitherTrampoline
in interface Either<ST,PT>
public <R> Either<ST,R> map(java.util.function.Function<? super PT,? extends R> mapper)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
public <RT1> Either<ST,RT1> flatMap(java.util.function.Function<? super PT,? extends MonadicValue<? extends RT1>> mapper)
MonadicValue
Optional.flatMap(Function)
Eval.now(1).map(i->i+2).flatMap(i->Eval.later(()->i*3);
//Eval[9]
public final void subscribe(org.reactivestreams.Subscriber<? super PT> sub)
public Either<ST,PT> filter(java.util.function.Predicate<? super PT> test)
Filters
of(1,2,3).filter(i->i>2);
//[3]
filter
in interface Filters<PT>
filter
in interface MonadicValue<PT>
filter
in interface Either<ST,PT>
filter
in interface Xor<ST,PT>
test
- to filter elements by, retaining matchespublic Value<ST> secondaryValue()
secondaryValue
in interface Either<ST,PT>
secondaryValue
in interface Xor<ST,PT>
public Either<ST,PT> secondaryToPrimayMap(java.util.function.Function<? super ST,? extends PT> fn)
Either
secondaryToPrimayMap
in interface Either<ST,PT>
secondaryToPrimayMap
in interface Xor<ST,PT>
fn
- Function to map secondary type to primarypublic <R> Either<R,PT> secondaryMap(java.util.function.Function<? super ST,? extends R> fn)
Either
secondaryMap
in interface Either<ST,PT>
secondaryMap
in interface Xor<ST,PT>
fn
- Transformation function for Left typespublic Either<ST,PT> secondaryPeek(java.util.function.Consumer<? super ST> action)
Either
secondaryPeek
in interface Either<ST,PT>
secondaryPeek
in interface Xor<ST,PT>
action
- Consumer to peek at the Left type valuepublic Either<ST,PT> peek(java.util.function.Consumer<? super PT> action)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
public Either<PT,ST> 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 Ior<ST,PT> toIor()
Value
public <R> R visit(java.util.function.Function<? super ST,? extends R> secondary, java.util.function.Function<? super PT,? extends R> primary)
Either
Either.right(10)
.visit(secondary->"no", primary->"yes")
//Either["yes"]
Either.left(90)
.visit(secondary->"no", primary->"yes")
//Either["no"]
public PT get()
public ST secondaryGet()
secondaryGet
in interface Either<ST,PT>
secondaryGet
in interface Xor<ST,PT>
public java.util.Optional<ST> secondaryToOptional()
secondaryToOptional
in interface Either<ST,PT>
secondaryToOptional
in interface Xor<ST,PT>
public ReactiveSeq<ST> secondaryToStream()
secondaryToStream
in interface Either<ST,PT>
secondaryToStream
in interface Xor<ST,PT>
public <LT1> Either<LT1,PT> secondaryFlatMap(java.util.function.Function<? super ST,? extends Xor<LT1,PT>> mapper)
Either
secondaryFlatMap
in interface Either<ST,PT>
secondaryFlatMap
in interface Xor<ST,PT>
mapper
- Flattening transformation functionpublic Either<ST,PT> secondaryToPrimayFlatMap(java.util.function.Function<? super ST,? extends Xor<ST,PT>> fn)
Either
secondaryToPrimayFlatMap
in interface Either<ST,PT>
secondaryToPrimayFlatMap
in interface Xor<ST,PT>
fn
- Transformation functionpublic void peek(java.util.function.Consumer<? super ST> stAction, java.util.function.Consumer<? super PT> ptAction)
public boolean isRight()
public boolean isLeft()
public <T2,R> Either<ST,R> combine(Value<? extends T2> app, java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
MonadicValue
Maybe<Integer> some = Maybe.just(10);
just.combine(Eval.now(20), this::add);
//Some[30]
Maybe<Integer> none = Maybe.none();
none.combine(Eval.now(20), this::add);
//None
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object