LT1 - First type (Left type)LT2 - Second typeLT3 - Third TypeLT4 - Fourth TypeRT - Right type (operations are performed on this type if present)public interface Either5<LT1,LT2,LT3,LT4,RT> extends Transformable<RT>, Filters<RT>, BiTransformable<LT4,RT>, To<Either5<LT1,LT2,LT3,LT4,RT>>, MonadicValue<RT>, java.util.function.Supplier<RT>
| Modifier and Type | Interface and Description |
|---|---|
static class |
Either5.CompletableEither5<ORG,LT1,LT2,LT3,RT> |
static class |
Either5.Lazy<ST,M,M2,M3,PT> |
static class |
Either5.Left1<ST,M,M2,M3,PT> |
static class |
Either5.Left2<ST,M,M2,M3,PT> |
static class |
Either5.Left3<ST,M,M2,M3,PT> |
static class |
Either5.Left4<ST,M,M2,M3,PT> |
static class |
Either5.Right<ST,M,M2,M3,PT> |
Value.ValueImpl<T>Convertable.SupplierToConvertable<T>Fn0.FunctionalOperations<R>, Fn0.Instances, Fn0.SupplierKind<R>| Modifier and Type | Method and Description |
|---|---|
static <LT1,LT2,LT3,LT4,RT> |
accumulate(Monoid<RT> reducer,
CollectionX<Either5<LT1,LT2,LT3,LT4,RT>> xors)
Accumulate the results only from those Either3 which have a Right type present, using the supplied Monoid (a combining BiFunction/BinaryOperator and identity element that takes two
input values of the same type and returns the combined result)
com.aol.cyclops2.Monoids . |
static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X,R> |
applyAny(Either5<LT1,LT2,LT3,LT4,RT> either) |
default int |
arity() |
default <U1,U2> Either5<LT1,LT2,LT3,U1,U2> |
bicast(java.lang.Class<U1> type1,
java.lang.Class<U2> type2)
Cast two data types simulatanously.
|
<R1,R2> Either5<LT1,LT2,LT3,R1,R2> |
bimap(java.util.function.Function<? super LT4,? extends R1> fn1,
java.util.function.Function<? super RT,? extends R2> fn2)
Transform this BiTransformable, changing two value types at once.
|
default Either5<LT1,LT2,LT3,LT4,RT> |
bipeek(java.util.function.Consumer<? super LT4> c1,
java.util.function.Consumer<? super RT> c2)
Peek at two data types simulatanously (typically to perform a side-effect with each data point)
|
default <R1,R2> Either5<LT1,LT2,LT3,R1,R2> |
bitrampoline(java.util.function.Function<? super LT4,? extends Trampoline<? extends R1>> mapper1,
java.util.function.Function<? super RT,? extends Trampoline<? extends R2>> mapper2)
Perform a tail-call optimized recursive transformation operation across two data points simultaneously
|
default <U> Either5<LT1,LT2,LT3,LT4,U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a reactiveStream to a given type, possibly throwing a
ClassCastException. |
default <R> Either5<LT1,LT2,LT3,LT4,R> |
coflatMap(java.util.function.Function<? super MonadicValue<RT>,R> mapper)
Perform a coflatMap operation.
|
default <T2,R> Either5<LT1,LT2,LT3,LT4,R> |
combine(Value<? extends T2> app,
java.util.function.BiFunction<? super RT,? super T2,? extends R> fn)
Lazily combine this ApplicativeFunctor with the supplied value via the supplied BiFunction
Example
|
default Either5<LT1,LT2,LT3,LT4,RT> |
combineEager(Monoid<RT> monoid,
MonadicValue<? extends RT> v2)
Eagerly combine two MonadicValues using the supplied monoid (@see ApplicativeFunctor for type appropraite i.e.
|
static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X> |
consumeAny(Either5<LT1,LT2,LT3,LT4,RT> either)
Static method useful as a method reference for fluent consumption of any value type stored in this Either
(will capture the lowest common type)
|
static <LT2,LT3,LT4,RT> |
either4() |
static <LT2,LT3,LT4,RT> |
either5()
Create a reactiveBuffer CompletableEither
|
Maybe<RT> |
filter(java.util.function.Predicate<? super RT> test)
Filter this Either4 resulting in a Maybe#none if it is not a Right instance or if the predicate does not
hold.
|
default Maybe<RT> |
filterNot(java.util.function.Predicate<? super RT> predicate)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
<RT1> Either5<LT1,LT2,LT3,LT4,RT1> |
flatMap(java.util.function.Function<? super RT,? extends MonadicValue<? extends RT1>> mapper)
Flattening transformation on this Either4.
|
default <RT1> Either5<LT1,LT2,LT3,LT4,RT1> |
flatMapI(java.util.function.Function<? super RT,? extends java.lang.Iterable<? extends RT1>> mapper)
A flattening transformation operation that takes the first value from the returned Iterable.
|
default <RT1> Either5<LT1,LT2,LT3,LT4,RT1> |
flatMapP(java.util.function.Function<? super RT,? extends org.reactivestreams.Publisher<? extends RT1>> mapper)
A flattening transformation operation that takes the first value from the returned Publisher.
|
default <R> Either5<LT1,LT2,LT3,LT4,R> |
flatMapS(java.util.function.Function<? super RT,? extends java.util.stream.Stream<? extends R>> mapper) |
static <LT,M1,B,T4,RT> |
foEval(Eval<B> middle)
Construct a Either4#Third from an Eval
|
default <R1,R> Either5<LT1,LT2,LT3,LT4,R> |
forEach2(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,? extends R> yieldingFunction)
Perform a two level nested internal iteration over this MonadicValue and the
supplied MonadicValue
|
default <R1,R> Either5<LT1,LT2,LT3,LT4,R> |
forEach2(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,java.lang.Boolean> filterFunction,
java.util.function.BiFunction<? super RT,? super R1,? extends R> yieldingFunction)
Perform a two level nested internal iteration over this MonadicValue and the
supplied reactiveStream
|
default <T2,R1,R2,R> |
forEach3(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super RT,? super R1,? super R2,? extends R> yieldingFunction)
Perform a three level nested internal iteration over this MonadicValue and the
supplied MonadicValues
|
default <T2,R1,R2,R> |
forEach3(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super RT,? super R1,? super R2,java.lang.Boolean> filterFunction,
Fn3<? super RT,? super R1,? super R2,? extends R> yieldingFunction)
Perform a three level nested internal iteration over this MonadicValue and the
supplied MonadicValues
|
default <T2,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super RT,? super R1,? super R2,? extends MonadicValue<R3>> value3,
Fn4<? super RT,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
Perform a four level nested internal iteration over this MonadicValue and the
supplied MonadicValues
|
default <T2,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super RT,? super R1,? super R2,? extends MonadicValue<R3>> value3,
Fn4<? super RT,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction,
Fn4<? super RT,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
Perform a four level nested internal iteration over this MonadicValue and the
supplied MonadicValues
Maybe.of(3)
.forEach4(a->Maybe.just(a+10),
(a,b)->Maybe.just(a+b),
(a,b,c)->Maybe.none(),
(a,b,c,d)->a+b+c<100,
(a,b,c,d)->a+b+c+d);
//Maybe.none
|
static <LT2,LT3,LT4,RT> |
fromFuture(Future<RT> future) |
static <ST,T,T2,T3,RT> |
fromIterable(java.lang.Iterable<RT> iterable)
Construct a Right Either4 from the supplied Iterable
|
static <LT1,LT2,LT3,LT4,RT> |
fromLazy(Eval<Either5<LT1,LT2,LT3,LT4,RT>> lazy) |
static <LT1,LT2,LT3,LT4,RT> |
fromMonadicValue(MonadicValue<RT> mv5) |
static <T1,T2,T3,T> |
fromPublisher(org.reactivestreams.Publisher<T> pub)
Lazily construct a Right Either from the supplied publisher
|
boolean |
isLeft1() |
boolean |
isLeft2() |
boolean |
isLeft3() |
boolean |
isLeft4() |
boolean |
isRight() |
static <LT,M1,B,T4,RT> |
left1(LT left)
Construct a Either4#Left1
|
static <LT,M1,B,T4,RT> |
left1Eval(Eval<LT> left)
Construct a Either4#Left1 from an Eval
|
static <LT,M1,B,T4,RT> |
left2(M1 middle)
Construct a Either4#Second
|
static <LT,M1,B,T4,RT> |
left2Eval(Eval<M1> middle)
Construct a Either4#Second from an Eval
|
static <LT,M1,B,T4,RT> |
left3(B middle)
Construct a Either4#Third
|
static <LT,M1,B,T4,RT> |
left3Eval(Eval<B> middle)
Construct a Either4#Third from an Eval
|
static <LT,M1,B,T4,RT> |
left4(T4 middle)
Construct a Either4#Third
|
static <LT,M1,B,T4,RT> |
left4Eval(Eval<T4> middle)
Construct a Either4#Third from an Eval
|
<R> Either5<LT1,LT2,LT3,LT4,R> |
map(java.util.function.Function<? super RT,? extends R> fn)
Transform this functor using the supplied transformation function
|
default Either5<LT1,LT2,LT3,LT4,MonadicValue<RT>> |
nest()
cojoin pattern.
|
default Maybe<RT> |
notNull()
Filter elements retaining only values which are not null
|
default <U> Maybe<U> |
ofType(java.lang.Class<? extends U> type)
Keep only those elements in a reactiveStream that are of a given type.
|
default Either5<LT1,LT2,LT3,LT4,RT> |
peek(java.util.function.Consumer<? super RT> c)
Peek at the current value of this Transformable, without transforming it
|
default <R> Either5<LT1,LT2,LT3,LT4,R> |
retry(java.util.function.Function<? super RT,? extends R> fn)
Retry a transformation if it fails.
|
default <R> Either5<LT1,LT2,LT3,LT4,R> |
retry(java.util.function.Function<? super RT,? extends R> fn,
int retries,
long delay,
java.util.concurrent.TimeUnit timeUnit)
Retry a transformation if it fails.
|
static <LT,M1,B,T4,RT> |
right(RT right)
Construct a Either4#Right
|
static <LT,M1,B,T4,RT> |
rightEval(Eval<RT> right)
Construct a Either4#Right from an Eval
|
static <LT1,LT2,LT3,LT4,PT> |
sequence(CollectionX<Either5<LT1,LT2,LT3,LT4,PT>> xors)
Turn a toX of Either3 into a singleUnsafe Either with Lists of values.
|
Either5<RT,LT2,LT3,LT4,LT1> |
swap1() |
Either5<LT1,RT,LT3,LT4,LT2> |
swap2() |
Either5<LT1,LT2,RT,LT4,LT3> |
swap3() |
Either5<LT1,LT2,LT3,RT,LT4> |
swap4() |
default Ior<LT1,RT> |
toIor()
Return an Ior that can be this object or a Ior.primary or Ior.secondary
|
default Trampoline<Either5<LT1,LT2,LT3,LT4,RT>> |
toTrampoline() |
default Xor<LT1,RT> |
toXor() |
default <R> Either5<LT1,LT2,LT3,LT4,R> |
trampoline(java.util.function.Function<? super RT,? extends Trampoline<? extends R>> mapper)
Performs a map operation that can call a recursive method without running out of stack space
|
static <LT1,LT2,LT3,LT4,PT,R> |
traverse(CollectionX<Either5<LT1,LT2,LT3,LT4,PT>> xors,
java.util.function.Function<? super PT,? extends R> fn)
Traverse a Collection of Either3 producing an Either4 with a ListX, applying the transformation function to every
element in the list
|
<T> Either5<LT1,LT2,LT3,LT4,T> |
unit(T unit) |
<R> R |
visit(java.util.function.Function<? super LT1,? extends R> left1,
java.util.function.Function<? super LT2,? extends R> left2,
java.util.function.Function<? super LT3,? extends R> left3,
java.util.function.Function<? super LT4,? extends R> left4,
java.util.function.Function<? super RT,? extends R> right)
Visit the types in this Either4, only one user supplied function is executed depending on the type
|
static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X> |
visitAny(java.util.function.Consumer<? super X> c,
Either5<LT1,LT2,LT3,LT4,RT> either) |
static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X,R> |
visitAny(Either5<LT1,LT2,LT3,LT4,RT> either,
java.util.function.Function<? super X,? extends R> fn) |
default Either5<LT1,LT2,LT3,LT4,RT> |
zip(java.util.function.BinaryOperator<Zippable<RT>> combiner,
Zippable<RT> app)
Combine two applicatives together using the provided BinaryOperator (Semigroup, Monoid and Reducer all
extend BinaryOperator - checkout SemigroupK and Monoids for a large number of canned combinations).
|
default <T2,R> Either5<LT1,LT2,LT3,LT4,R> |
zip(java.lang.Iterable<? extends T2> app,
java.util.function.BiFunction<? super RT,? super T2,? extends R> fn)
Zip (combine) this Zippable with the supplied Iterable using the supplied combining function
|
default <U> Either5<LT1,LT2,LT3,LT4,org.jooq.lambda.tuple.Tuple2<RT,U>> |
zip(java.lang.Iterable<? extends U> other)
Zip (combine) this Zippable with the supplied Iterable combining both into a Tuple2
|
default <S,U> Either5<LT1,LT2,LT3,LT4,org.jooq.lambda.tuple.Tuple3<RT,S,U>> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third)
zip 3 Streams into one
|
default <S,U,R> Either5<LT1,LT2,LT3,LT4,R> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third,
Fn3<? super RT,? super S,? super U,? extends R> fn3) |
default <T2,T3,T4> Either5<LT1,LT2,LT3,LT4,org.jooq.lambda.tuple.Tuple4<RT,T2,T3,T4>> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth)
zip 4 Streams into 1
|
default <T2,T3,T4,R> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth,
Fn4<? super RT,? super T2,? super T3,? super T4,? extends R> fn) |
default <T2,R> Either5<LT1,LT2,LT3,LT4,R> |
zipP(org.reactivestreams.Publisher<? extends T2> app,
java.util.function.BiFunction<? super RT,? super T2,? extends R> fn)
Zip (combine) this Zippable with the supplied Publisher, using the supplied combining function
|
default <U> Either5<LT1,LT2,LT3,LT4,org.jooq.lambda.tuple.Tuple2<RT,U>> |
zipP(org.reactivestreams.Publisher<? extends U> other) |
default <U> Either5<LT1,LT2,LT3,LT4,org.jooq.lambda.tuple.Tuple2<RT,U>> |
zipS(java.util.stream.Stream<? extends U> other)
Zip (combine) this Zippable with the supplied Stream combining both into a Tuple2
|
default <U,R> Either5<LT1,LT2,LT3,LT4,R> |
zipS(java.util.stream.Stream<? extends U> other,
java.util.function.BiFunction<? super RT,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Stream, using the supplied combining function
|
default <R> Either5<LT1,LT2,LT3,LT4,R> |
zipWith(java.lang.Iterable<java.util.function.Function<? super RT,? extends R>> fn) |
default <R> Either5<LT1,LT2,LT3,LT4,R> |
zipWithP(org.reactivestreams.Publisher<java.util.function.Function<? super RT,? extends R>> fn) |
default <R> Either5<LT1,LT2,LT3,LT4,R> |
zipWithS(java.util.stream.Stream<java.util.function.Function<? super RT,? extends R>> fn) |
apply, generate, iterate, iterator, mkString, newSubscriber, of, stream, subscribe, test, toEither, toEval, toEvalAlways, toEvalLater, toEvalNow, toLeft, toMaybe, toMaybeEager, toRight, toTry, toTry, toTry, toXorendsWith, 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, xMatchcollect, fromSupplier, get, isPresent, orElse, orElseGet, orElseThrow, toCompletableFuture, toCompletableFutureAsync, toFuture, toFutureAsync, toOptional, toStream, visitstatic <LT2,LT3,LT4,RT> Either5.CompletableEither5<RT,LT2,LT3,LT4,RT> either5()
___Example 1___
CompletableEither<Integer,Integer> completable = Either4.either4();
Either4<Throwable,String,Integer> mapped = completable.map(i->i*2)
.flatMap(i->Eval.later(()->i+1));
completable.complete(5);
mapped.printOut();
//11
___Example 2___
CompletableEither<Integer,Integer> completable = Either4.either4();
Either4<Throwable,String,Integer> mapped = completable.map(i->i*2)
.flatMap(i->Eval.later(()->i+1));
completable.complete(null);
//Either4:Left4[NoSuchElementException]
___Example 3___
CompletableEither<Integer,Integer> completable = Either4.either4();
Either4<Throwable,String,Integer> mapped = completable.map(i->i*2)
.flatMap(i->Eval.later(()->i+1));
completable.complete(new IllegalStateException());
//Either:Left[IllegalStateElementException]
RT - static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X> java.util.function.Consumer<java.util.function.Consumer<? super X>> consumeAny(Either5<LT1,LT2,LT3,LT4,RT> either)
myEither.to(Either5::consumeAny)
.accept(System.out::println);
either - Either to consume value forstatic <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X,R> java.util.function.Function<java.util.function.Function<? super X,R>,R> applyAny(Either5<LT1,LT2,LT3,LT4,RT> either)
static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X,R> R visitAny(Either5<LT1,LT2,LT3,LT4,RT> either, java.util.function.Function<? super X,? extends R> fn)
static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X> X visitAny(java.util.function.Consumer<? super X> c,
Either5<LT1,LT2,LT3,LT4,RT> either)
static <LT1,LT2,LT3,LT4,RT> Either5<LT1,LT2,LT3,LT4,RT> fromMonadicValue(MonadicValue<RT> mv5)
static <LT2,LT3,LT4,RT> Either5<java.lang.Throwable,LT2,LT3,LT4,RT> either4()
static <LT1,LT2,LT3,LT4,RT> Either5<LT1,LT2,LT3,LT4,RT> fromLazy(Eval<Either5<LT1,LT2,LT3,LT4,RT>> lazy)
static <LT2,LT3,LT4,RT> Either5<java.lang.Throwable,LT2,LT3,LT4,RT> fromFuture(Future<RT> future)
static <LT1,LT2,LT3,LT4,PT> Either5<ListX<LT1>,ListX<LT2>,ListX<LT3>,ListX<LT4>,ListX<PT>> sequence(CollectionX<Either5<LT1,LT2,LT3,LT4,PT>> xors)
Either4<String,String,String,Integer> just = Either4.right(10);
Either4<String,String,String,Integer> none = Either4.left("none");
Either4<ListX<String>,ListX<String>,ListX<String>,ListX<Integer>> xors =Either4.sequence(ListX.of(just,none,Either4.right(1)));
//Eitehr.right(ListX.of(10,1)));
Either3 - Either3 to sequencestatic <LT1,LT2,LT3,LT4,PT,R> Either5<ListX<LT1>,ListX<LT2>,ListX<LT3>,ListX<LT4>,ListX<R>> traverse(CollectionX<Either5<LT1,LT2,LT3,LT4,PT>> xors, java.util.function.Function<? super PT,? extends R> fn)
xors - Either4s to sequence and transformfn - Transformation functionstatic <LT1,LT2,LT3,LT4,RT> Either5<ListX<LT1>,ListX<LT2>,ListX<LT3>,ListX<LT4>,RT> accumulate(Monoid<RT> reducer, CollectionX<Either5<LT1,LT2,LT3,LT4,RT>> xors)
com.aol.cyclops2.Monoids .
Either4<String,String,String,Integer> just = Either4.right(10);
Either4<String,String,String,Integer> none = Either4.left("none");
Either4<ListX<String>,ListX<String>,Integer> xors = Either4.accumulatePrimary(Monoids.intSum,ListX.of(just,none,Either4.right(1)));
//Either4.right(11);
xors - Collection of Eithers to accumulate primary valuesreducer - Reducer to accumulate resultsstatic <T1,T2,T3,T> Either5<java.lang.Throwable,T1,T2,T3,T> fromPublisher(org.reactivestreams.Publisher<T> pub)
ReactiveSeq<Integer> reactiveStream = ReactiveSeq.of(1,2,3);
Either5<Throwable,String,String,String,Integer> lazy = Either5.fromPublisher(reactiveStream);
//Either[1]
pub - Publisher to construct an Either fromstatic <ST,T,T2,T3,RT> Either5<ST,T,T2,T3,RT> fromIterable(java.lang.Iterable<RT> iterable)
List<Integer> list = Arrays.asList(1,2,3);
Either4<Throwable,String,Integer> future = Either4.fromIterable(list);
//Either4[1]
iterable - Iterable to construct an Either fromstatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> rightEval(Eval<RT> right)
right - Eval to construct Either4#Right fromstatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> left1Eval(Eval<LT> left)
left - Eval to construct Either4#Left1 fromstatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> right(RT right)
right - Value to storestatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> left1(LT left)
left - Value to storestatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> left2(M1 middle)
middle - Value to storestatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> left3(B middle)
middle - Value to storestatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> left4(T4 middle)
middle - Value to storestatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> left2Eval(Eval<M1> middle)
second - Eval to construct Either4#middle fromstatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> left3Eval(Eval<B> middle)
third - Eval to construct Either4#middle fromstatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> left4Eval(Eval<T4> middle)
third - Eval to construct Either4#middle fromstatic <LT,M1,B,T4,RT> Either5<LT,M1,B,T4,RT> foEval(Eval<B> middle)
third - Eval to construct Either4#middle fromdefault int arity()
arity in interface MonadicValue<RT>default <R> Either5<LT1,LT2,LT3,LT4,R> zipWith(java.lang.Iterable<java.util.function.Function<? super RT,? extends R>> fn)
default <R> Either5<LT1,LT2,LT3,LT4,R> zipWithS(java.util.stream.Stream<java.util.function.Function<? super RT,? extends R>> fn)
default <R> Either5<LT1,LT2,LT3,LT4,R> zipWithP(org.reactivestreams.Publisher<java.util.function.Function<? super RT,? extends R>> fn)
default <R> Either5<LT1,LT2,LT3,LT4,R> retry(java.util.function.Function<? super RT,? extends R> fn)
Transformable
given(serviceMock.applyHKT(anyInt())).willThrow(
new RuntimeException(new SocketException("First")),
new RuntimeException(new IOException("Second"))).willReturn(
"42");
String result = ReactiveSeq.of( 1, 2, 3)
.retry(serviceMock)
.firstValue();
//result = 42
retry in interface Transformable<RT>fn - Function to retry if failsdefault <U> Either5<LT1,LT2,LT3,LT4,org.jooq.lambda.tuple.Tuple2<RT,U>> zipP(org.reactivestreams.Publisher<? extends U> other)
default <R> Either5<LT1,LT2,LT3,LT4,R> retry(java.util.function.Function<? super RT,? extends R> fn, int retries, long delay, java.util.concurrent.TimeUnit timeUnit)
Transformable
given(serviceMock.applyHKT(anyInt())).willThrow(
new RuntimeException(new SocketException("First")),
new RuntimeException(new IOException("Second"))).willReturn(
"42");
String result = ReactiveSeq.of( 1, 2, 3)
.retry(serviceMock, 7, 2, TimeUnit.SECONDS)
.firstValue();
//result = 42
retry in interface Transformable<RT>fn - Function to retry if failsretries - Number of retriesdelay - Delay in TimeUnitstimeUnit - TimeUnit to use for delaydefault <S,U> Either5<LT1,LT2,LT3,LT4,org.jooq.lambda.tuple.Tuple3<RT,S,U>> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third)
Zippable
List<Tuple3<Integer, Integer, Character>> list = of(1, 2, 3, 4, 5, 6).zip3(of(100, 200, 300, 400), of('a', 'b', 'c')).collect(CyclopsCollectors.toList());
// [[1,100,'a'],[2,200,'b'],[3,300,'c']]
default <S,U,R> Either5<LT1,LT2,LT3,LT4,R> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third, Fn3<? super RT,? super S,? super U,? extends R> fn3)
default <T2,T3,T4> Either5<LT1,LT2,LT3,LT4,org.jooq.lambda.tuple.Tuple4<RT,T2,T3,T4>> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth)
Zippable
List<Tuple4<Integer, Integer, Character, String>> list = of(1, 2, 3, 4, 5, 6).zip4(of(100, 200, 300, 400), of('a', 'b', 'c'), of("hello", "world"))
.collect(CyclopsCollectors.toList());
// [[1,100,'a',"hello"],[2,200,'b',"world"]]
default <T2,T3,T4,R> Either5<LT1,LT2,LT3,LT4,R> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth, Fn4<? super RT,? super T2,? super T3,? super T4,? extends R> fn)
default <R> Either5<LT1,LT2,LT3,LT4,R> flatMapS(java.util.function.Function<? super RT,? extends java.util.stream.Stream<? extends R>> mapper)
flatMapS in interface MonadicValue<RT>default <RT1> Either5<LT1,LT2,LT3,LT4,RT1> flatMapI(java.util.function.Function<? super RT,? extends java.lang.Iterable<? extends RT1>> mapper)
MonadicValue
Maybe.just(1).map(i->i+2).flatMapI(i->Arrays.asList(()->i*3,20);
//Maybe[9]
flatMapI in interface MonadicValue<RT>mapper - transformation functiondefault <RT1> Either5<LT1,LT2,LT3,LT4,RT1> flatMapP(java.util.function.Function<? super RT,? extends org.reactivestreams.Publisher<? extends RT1>> mapper)
MonadicValue
Future.ofResult(1).map(i->i+2).flatMapP(i->Flux.just(()->i*3,20);
//Future[9]
flatMapP in interface MonadicValue<RT>mapper - transformation function<R> R visit(java.util.function.Function<? super LT1,? extends R> left1, java.util.function.Function<? super LT2,? extends R> left2, java.util.function.Function<? super LT3,? extends R> left3, java.util.function.Function<? super LT4,? extends R> left4, java.util.function.Function<? super RT,? extends R> right)
left1 - Function to execute if this Either4 is a Left1 instanceleft2 - Function to execute if this Either4 is a Left2 instanceleft3 - Function to execute if this Either4 is a Left3 instanceright - Function to execute if this Either4 is a right instanceMaybe<RT> filter(java.util.function.Predicate<? super RT> test)
<RT1> Either5<LT1,LT2,LT3,LT4,RT1> flatMap(java.util.function.Function<? super RT,? extends MonadicValue<? extends RT1>> mapper)
flatMap in interface MonadicValue<RT>mapper - Mapping functionboolean isRight()
boolean isLeft1()
boolean isLeft2()
boolean isLeft3()
boolean isLeft4()
default <U> Maybe<U> ofType(java.lang.Class<? extends U> type)
Filters
// (1, 2, 3) ReactiveSeq.of(1, "a", 2, "b",3).ofType(Integer.class)
default Maybe<RT> filterNot(java.util.function.Predicate<? super RT> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
default Maybe<RT> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
<R1,R2> Either5<LT1,LT2,LT3,R1,R2> bimap(java.util.function.Function<? super LT4,? extends R1> fn1, java.util.function.Function<? super RT,? extends R2> fn2)
BiTransformable
MapX<String,Integer> map = MapXs.of("hello",2);
MapX<String,Integer> transformedMap = map.bimap(s->s+" world",i->i*4);
//["hello world",8]
bimap in interface BiTransformable<LT4,RT>fn1 - transformation function for the first typefn2 - transformation function for the second type<R> Either5<LT1,LT2,LT3,LT4,R> map(java.util.function.Function<? super RT,? extends R> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
map in interface MonadicValue<RT>map in interface Transformable<RT>fn - Transformation functiondefault Ior<LT1,RT> toIor()
default <R> Either5<LT1,LT2,LT3,LT4,R> coflatMap(java.util.function.Function<? super MonadicValue<RT>,R> mapper)
MonadicValue
Maybe.none().coflatMap(m -> m.isPresent() ? m.get() : 10);
//Maybe[10]
coflatMap in interface MonadicValue<RT>mapper - Mapping / transformation functiondefault Either5<LT1,LT2,LT3,LT4,MonadicValue<RT>> nest()
MonadicValuenest in interface MonadicValue<RT>default <T2,R1,R2,R3,R> Either5<LT1,LT2,LT3,LT4,R> forEach4(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super RT,? super R1,? super R2,? extends MonadicValue<R3>> value3, Fn4<? super RT,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
MonadicValue
Maybe.of(3)
.forEach4(a->Maybe.just(a+10),
(a,b)->Maybe.just(a+b),
(a,b,c)->Maybe.none(),
(a,b,c,d)->a+b+c+d);
//Maybe.none
forEach4 in interface MonadicValue<RT>value1 - Nested MonadicValue to iterate overvalue2 - Nested MonadicValue to iterate overvalue3 - Nested MonadicValue to iterate overyieldingFunction - Function with pointers to the current element from both
MonadicValue that generates the new elementsdefault <T2,R1,R2,R3,R> Either5<LT1,LT2,LT3,LT4,R> forEach4(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super RT,? super R1,? super R2,? extends MonadicValue<R3>> value3, Fn4<? super RT,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction, Fn4<? super RT,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
MonadicValueMaybe.of(3)
.forEach4(a->Maybe.just(a+10),
(a,b)->Maybe.just(a+b),
(a,b,c)->Maybe.none(),
(a,b,c,d)->a+b+c<100,
(a,b,c,d)->a+b+c+d);
//Maybe.none
forEach4 in interface MonadicValue<RT>value1 - Nested MonadicValue to iterate overvalue2 - Nested MonadicValue to iterate overvalue3 - Nested MonadicValue to iterate overfilterFunction - Filter to applyHKT over elements before passing non-filtered
values to the yielding functionyieldingFunction - Function with pointers to the current element from both
MonadicValue that generates the new elementsdefault <T2,R1,R2,R> Either5<LT1,LT2,LT3,LT4,R> forEach3(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super RT,? super R1,? super R2,? extends R> yieldingFunction)
MonadicValue
Maybe.of(3)
.forEach3(a->Maybe.just(a+10),
(a,b)->Maybe.just(a+b),
(a,b,c)->a+b+c<100,
(a,b,c)->a+b+c);
//Maybe[32]
forEach3 in interface MonadicValue<RT>value1 - Nested MonadicValue to iterate overvalue2 - Nested MonadicValue to iterate overyieldingFunction - Function with pointers to the current element from both
MonadicValue that generates the new elementsdefault <T2,R1,R2,R> Either5<LT1,LT2,LT3,LT4,R> forEach3(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super RT,? super R1,? super R2,java.lang.Boolean> filterFunction, Fn3<? super RT,? super R1,? super R2,? extends R> yieldingFunction)
MonadicValue
Maybe.of(3)
.forEach3(a->Maybe.just(a+10),
(a,b)->Maybe.just(a+b),
(a,b,c)->a+b+c<100,
(a,b,c)->a+b+c);
//Maybe[32]
forEach3 in interface MonadicValue<RT>value1 - Nested MonadicValue to iterate overvalue2 - Nested MonadicValue to iterate overfilterFunction - Filter to applyHKT over elements before passing non-filtered
values to the yielding functionyieldingFunction - Function with pointers to the current element from both
MonadicValue that generates the new elementsdefault <R1,R> Either5<LT1,LT2,LT3,LT4,R> forEach2(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends R> yieldingFunction)
MonadicValue
Maybe.of(3)
.forEach2(a->Maybe.none(),
(a,b)->a+b);
//Maybe.none()
forEach2 in interface MonadicValue<RT>value1 - Nested Monadic Type to iterate overyieldingFunction - Function with pointers to the current element from both
monad types that generates the new elementsdefault <R1,R> Either5<LT1,LT2,LT3,LT4,R> forEach2(java.util.function.Function<? super RT,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super RT,? super R1,java.lang.Boolean> filterFunction, java.util.function.BiFunction<? super RT,? super R1,? extends R> yieldingFunction)
MonadicValue
Maybe.of(3)
.forEach2(a->Maybe.none(),
a->b-> a<3 && b>10,
(a,b)->a+b);
//Maybe.none()
forEach2 in interface MonadicValue<RT>filterFunction - Filter to applyHKT over elements before passing non-filtered
values to the yielding functionyieldingFunction - Function with pointers to the current element from both
Streams that generates the new elementsdefault Either5<LT1,LT2,LT3,LT4,RT> combineEager(Monoid<RT> monoid, MonadicValue<? extends RT> v2)
MonadicValue
Monoid<Integer> add = Monoid.of(1,SemigroupK.intSum);
Maybe.of(10).combineEager(add,Maybe.none());
//Maybe[10]
Maybe.none().combineEager(add,Maybe.of(10));
//Maybe[10]
Maybe.none().combineEager(add,Maybe.none());
//Maybe.none()
Maybe.of(10).combineEager(add,Maybe.of(10));
//Maybe[20]
Monoid<Integer> firstNonNull = Monoid.of(null , SemigroupK.firstNonNull());
Maybe.of(10).combineEager(firstNonNull,Maybe.of(10));
//Maybe[10]
combineEager in interface MonadicValue<RT>default <T2,R> Either5<LT1,LT2,LT3,LT4,R> combine(Value<? extends T2> app, java.util.function.BiFunction<? super RT,? 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
combine in interface MonadicValue<RT>app - Value to combine with this one.fn - BiFunction to combine themdefault Either5<LT1,LT2,LT3,LT4,RT> zip(java.util.function.BinaryOperator<Zippable<RT>> combiner, Zippable<RT> app)
Zippablezip in interface Zippable<RT>Semigroup,
Semigroups,
Monoid,
To lift any Semigroup (or monoid) up to handling Applicatives use the combineApplicatives operator in SemigroupK
{@see com.aol.cyclops2.SemigroupK#combineApplicatives(BiFunction) } or Monoids
{ {@see com.aol.cyclops2.Monoids#combineApplicatives(java.util.function.Function, com.aol.cyclops2.function.Monoid)
}
{@code
BinaryOperator> sumMaybes = SemigroupK.combineScalarFunctors(SemigroupK.intSum);
Maybe.just(1).zip(sumMaybes, Maybe.just(5))
//Maybe.just(6));
}
default <U,R> Either5<LT1,LT2,LT3,LT4,R> zipS(java.util.stream.Stream<? extends U> other, java.util.function.BiFunction<? super RT,? super U,? extends R> zipper)
Zippabledefault <U> Either5<LT1,LT2,LT3,LT4,org.jooq.lambda.tuple.Tuple2<RT,U>> zipS(java.util.stream.Stream<? extends U> other)
Zippabledefault <U> Either5<LT1,LT2,LT3,LT4,org.jooq.lambda.tuple.Tuple2<RT,U>> zip(java.lang.Iterable<? extends U> other)
Zippabledefault <T2,R> Either5<LT1,LT2,LT3,LT4,R> zip(java.lang.Iterable<? extends T2> app, java.util.function.BiFunction<? super RT,? super T2,? extends R> fn)
Zippabledefault <T2,R> Either5<LT1,LT2,LT3,LT4,R> zipP(org.reactivestreams.Publisher<? extends T2> app, java.util.function.BiFunction<? super RT,? super T2,? extends R> fn)
Zippabledefault Either5<LT1,LT2,LT3,LT4,RT> bipeek(java.util.function.Consumer<? super LT4> c1, java.util.function.Consumer<? super RT> c2)
BiTransformable
MapX<String,Integer> map = MapXs.of("hello",2);
map.bipeek(s->System.out.pritnln("key = " + s),System.out::println);
bipeek in interface BiTransformable<LT4,RT>c1 - consumer for the first typec2 - consumer for the second typedefault <U1,U2> Either5<LT1,LT2,LT3,U1,U2> bicast(java.lang.Class<U1> type1, java.lang.Class<U2> type2)
BiTransformable
MapX<Animal,Food> map = MapXs.of(cow,grass);
MapX<Mamaml,Vegitation> herbervoreMammals = map.bicast(Mammal.class,Vegitation.class);
bicast in interface BiTransformable<LT4,RT>default <R1,R2> Either5<LT1,LT2,LT3,R1,R2> bitrampoline(java.util.function.Function<? super LT4,? extends Trampoline<? extends R1>> mapper1, java.util.function.Function<? super RT,? extends Trampoline<? extends R2>> mapper2)
BiTransformablebitrampoline in interface BiTransformable<LT4,RT>mapper1 - transformation function for the first typemapper2 - transformation function for the second typedefault <U> Either5<LT1,LT2,LT3,LT4,U> cast(java.lang.Class<? extends U> type)
TransformableClassCastException.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)cast in interface Transformable<RT>default Either5<LT1,LT2,LT3,LT4,RT> peek(java.util.function.Consumer<? super RT> c)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
peek in interface Transformable<RT>c - Consumer that recieves each element from this Transformabledefault <R> Either5<LT1,LT2,LT3,LT4,R> trampoline(java.util.function.Function<? super RT,? extends Trampoline<? extends R>> mapper)
Transformable
ReactiveSeq.of(10,20,30,40)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
Trampoline<Long> fibonacci(int i){
return fibonacci(i,1,0);
}
Trampoline<Long> fibonacci(int n, long a, long b) {
return n == 0 ? Trampoline.done(b) : Trampoline.more( ()->fibonacci(n-1, a+b, a));
}
55
6765
832040
102334155
ReactiveSeq.of(10_000,200_000,3_000_000,40_000_000)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
completes successfully
trampoline in interface Transformable<RT>mapper - TCO Transformation function