LT1
- First type (Left type)LT2
- Second typeLT3
- Third TypeLT4
- Fourth TypeRT
- Right type (operations are performed on this type if present)public interface LazyEither5<LT1,LT2,LT3,LT4,RT> extends Transformable<RT>, Filters<RT>, BiTransformable<LT4,RT>, To<LazyEither5<LT1,LT2,LT3,LT4,RT>>, OrElseValue<RT,LazyEither5<LT1,LT2,LT3,LT4,RT>>, Unit<RT>, Sealed5<LT1,LT2,LT3,LT4,RT>, Value<RT>
Modifier and Type | Interface and Description |
---|---|
static class |
LazyEither5.CompletableEither5<ORG,LT1,LT2,LT3,RT> |
static class |
LazyEither5.Lazy<ST,M,M2,M3,PT> |
static class |
LazyEither5.Left1<ST,M,M2,M3,PT> |
static class |
LazyEither5.Left2<ST,M,M2,M3,PT> |
static class |
LazyEither5.Left3<ST,M,M2,M3,PT> |
static class |
LazyEither5.Left4<ST,M,M2,M3,PT> |
static class |
LazyEither5.Right<ST,M,M2,M3,PT> |
Modifier and Type | Method and Description |
---|---|
static <LT1,LT2,LT3,LT4,RT> |
accumulate(Monoid<RT> reducer,
java.lang.Iterable<LazyEither5<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.oath.cyclops.Monoids . |
static <ST,T,T2,T3,RT> |
always(java.util.function.Supplier<LazyEither5<ST,T,T2,T3,RT>> lazy) |
static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X,R> |
applyAny(LazyEither5<LT1,LT2,LT3,LT4,RT> either) |
<R1,R2> LazyEither5<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 LazyEither5<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 <R> LazyEither5<LT1,LT2,LT3,LT4,R> |
coflatMap(java.util.function.Function<? super LazyEither5<LT1,LT2,LT3,LT4,RT>,R> mapper) |
static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X> |
consumeAny(LazyEither5<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 reactive 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 LazyEither5<LT1,LT2,LT3,LT4,RT> |
filter(java.util.function.Predicate<? super RT> test,
java.util.function.Function<? super RT,? extends LT1> rightToLeft) |
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> LazyEither5<LT1,LT2,LT3,LT4,RT1> |
flatMap(java.util.function.Function<? super RT,? extends LazyEither5<LT1,LT2,LT3,LT4,? extends RT1>> mapper)
Flattening transformation on this Either4.
|
static <LT,M1,B,T4,RT> |
foEval(Eval<B> middle)
Construct a Either4#Third from an Eval
|
default <R> R |
fold(java.util.function.Function<? super LT1,? extends R> fn1,
java.util.function.Function<? super LT2,? extends R> fn2,
java.util.function.Function<? super LT3,? extends R> fn3,
java.util.function.Function<? super LT4,? extends R> fn4,
java.util.function.Function<? super RT,? extends R> fn5) |
static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X,R> |
foldAny(LazyEither5<LT1,LT2,LT3,LT4,RT> either,
java.util.function.Function<? super X,? extends R> fn) |
default <R1,R> LazyEither5<LT1,LT2,LT3,LT4,R> |
forEach2(java.util.function.Function<? super RT,? extends LazyEither5<LT1,LT2,LT3,LT4,R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,? extends R> yieldingFunction) |
default <T2,R1,R2,R> |
forEach3(java.util.function.Function<? super RT,? extends LazyEither5<LT1,LT2,LT3,LT4,R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,? extends LazyEither5<LT1,LT2,LT3,LT4,R2>> value2,
Function3<? super RT,? super R1,? super R2,? extends R> yieldingFunction) |
default <T2,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super RT,? extends LazyEither5<LT1,LT2,LT3,LT4,R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,? extends LazyEither5<LT1,LT2,LT3,LT4,R2>> value2,
Function3<? super RT,? super R1,? super R2,? extends LazyEither5<LT1,LT2,LT3,LT4,R3>> value3,
Function4<? super RT,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
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<LazyEither5<LT1,LT2,LT3,LT4,RT>> lazy) |
static <T1,T2,T3,T> |
fromPublisher(org.reactivestreams.Publisher<T> pub)
Lazily construct a Right Either from the supplied publisher
|
Option<RT> |
get() |
boolean |
isLeft1() |
boolean |
isLeft2() |
boolean |
isLeft3() |
boolean |
isLeft4() |
boolean |
isRight() |
static <ST,T,T2,T3,RT> |
later(java.util.function.Supplier<LazyEither5<ST,T,T2,T3,RT>> lazy) |
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> LazyEither5<LT1,LT2,LT3,LT4,R> |
map(java.util.function.Function<? super RT,? extends R> fn)
Transform this functor using the supplied transformation function
|
default LazyEither5<LT1,LT2,LT3,LT4,LazyEither5<LT1,LT2,LT3,LT4,RT>> |
nest() |
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 stream that are of a given type.
|
default LazyEither5<LT1,LT2,LT3,LT4,RT> |
peek(java.util.function.Consumer<? super RT> c)
Peek at the current value of this Transformable, without transforming it
|
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(java.lang.Iterable<? extends LazyEither5<LT1,LT2,LT3,LT4,PT>> xors)
Turn a toX of Either3 into a single Either with Lists of values.
|
static <L1,L2,L3,L4,T> |
sequence(ReactiveSeq<? extends LazyEither5<L1,L2,L3,L4,T>> stream) |
LazyEither5<RT,LT2,LT3,LT4,LT1> |
swap1() |
LazyEither5<LT1,RT,LT3,LT4,LT2> |
swap2() |
LazyEither5<LT1,LT2,RT,LT4,LT3> |
swap3() |
LazyEither5<LT1,LT2,LT3,RT,LT4> |
swap4() |
default Either<LT1,RT> |
toEither() |
default Ior<LT1,RT> |
toIor()
Return an Ior that can be this object or a Ior.right or Ior.left
|
default Trampoline<LazyEither5<LT1,LT2,LT3,LT4,RT>> |
toTrampoline() |
static <L1,L2,L3,L4,T,R> |
traverse(java.util.function.Function<? super T,? extends R> fn,
ReactiveSeq<LazyEither5<L1,L2,L3,L4,T>> stream) |
static <LT1,LT2,LT3,LT4,PT,R> |
traverse(java.lang.Iterable<LazyEither5<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 Seq, applying the transformation function to every
element in the list
|
<T> LazyEither5<LT1,LT2,LT3,LT4,T> |
unit(T unit) |
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,
LazyEither5<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(LazyEither5<LT1,LT2,LT3,LT4,RT> either,
java.util.function.Function<? super X,? extends R> fn)
Deprecated.
|
default <T2,R> LazyEither5<LT1,LT2,LT3,LT4,R> |
zip(LazyEither5<LT1,LT2,LT3,LT4,? extends T2> app,
java.util.function.BiFunction<? super RT,? super T2,? extends R> fn) |
orElseUse, orElseUse
asSupplier, collect, fold, forEach, generate, isPresent, iterate, iterator, mkString, nonEmptyList, nonEmptyListGet, orElse, orElseGet, print, print, printErr, printOut, stream, subscribe, toEither, toLazyEither, toLeft, toMaybe, toOption, toOptional, toRight, toTry, toTry, toTry
static <LT2,LT3,LT4,RT> LazyEither5.CompletableEither5<RT,LT2,LT3,LT4,RT> either5()
___Example 1___
CompletableEither<Integer,Integer> completable = Either4.lazyEither4();
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.lazyEither4();
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.lazyEither4();
Either4<Throwable,String,Integer> mapped = completable.map(i->i*2)
.flatMap(i->Eval.later(()->i+1));
completable.complete(new IllegalStateException());
//Either:Left[IllegalStateElementException]
RT
- default LazyEither5<LT1,LT2,LT3,LT4,RT> filter(java.util.function.Predicate<? super RT> test, java.util.function.Function<? super RT,? extends LT1> rightToLeft)
default <R> R fold(java.util.function.Function<? super LT1,? extends R> fn1, java.util.function.Function<? super LT2,? extends R> fn2, java.util.function.Function<? super LT3,? extends R> fn3, java.util.function.Function<? super LT4,? extends R> fn4, java.util.function.Function<? super RT,? extends R> fn5)
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(LazyEither5<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(LazyEither5<LT1,LT2,LT3,LT4,RT> either)
@Deprecated static <X,LT1 extends X,LT2 extends X,LT3 extends X,LT4 extends X,RT extends X,R> R visitAny(LazyEither5<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,R> R foldAny(LazyEither5<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, LazyEither5<LT1,LT2,LT3,LT4,RT> either)
static <LT2,LT3,LT4,RT> LazyEither5<java.lang.Throwable,LT2,LT3,LT4,RT> either4()
static <LT1,LT2,LT3,LT4,RT> LazyEither5<LT1,LT2,LT3,LT4,RT> fromLazy(Eval<LazyEither5<LT1,LT2,LT3,LT4,RT>> lazy)
static <LT2,LT3,LT4,RT> LazyEither5<java.lang.Throwable,LT2,LT3,LT4,RT> fromFuture(Future<RT> future)
static <LT1,LT2,LT3,LT4,PT> LazyEither5<LT1,LT2,LT3,LT4,ReactiveSeq<PT>> sequence(java.lang.Iterable<? extends LazyEither5<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<Seq<String>,Seq<String>,Seq<String>,Seq<Integer>> xors =Either4.sequence(Seq.of(just,none,Either4.right(1)));
//Eitehr.right(Seq.of(10,1)));
xors
- Either3 to sequencestatic <L1,L2,L3,L4,T> LazyEither5<L1,L2,L3,L4,ReactiveSeq<T>> sequence(ReactiveSeq<? extends LazyEither5<L1,L2,L3,L4,T>> stream)
static <L1,L2,L3,L4,T,R> LazyEither5<L1,L2,L3,L4,ReactiveSeq<R>> traverse(java.util.function.Function<? super T,? extends R> fn, ReactiveSeq<LazyEither5<L1,L2,L3,L4,T>> stream)
static <LT1,LT2,LT3,LT4,PT,R> LazyEither5<LT1,LT2,LT3,LT4,ReactiveSeq<R>> traverse(java.lang.Iterable<LazyEither5<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> LazyEither5<LT1,LT2,LT3,LT4,RT> accumulate(Monoid<RT> reducer, java.lang.Iterable<LazyEither5<LT1,LT2,LT3,LT4,RT>> xors)
com.oath.cyclops.Monoids
.
Either4<String,String,String,Integer> just = Either4.right(10);
Either4<String,String,String,Integer> none = Either4.left("none");
Either4<Seq<String>,Seq<String>,Integer> xors = Either4.accumulateRight(Monoids.intSum,Seq.of(just,none,Either4.right(1)));
//Either4.right(11);
xors
- Collection of Eithers to accumulate right valuesreducer
- Reducer to accumulate resultsstatic <T1,T2,T3,T> LazyEither5<java.lang.Throwable,T1,T2,T3,T> fromPublisher(org.reactivestreams.Publisher<T> pub)
ReactiveSeq<Integer> stream = ReactiveSeq.of(1,2,3);
Either5<Throwable,String,String,String,Integer> lazy = Either5.fromPublisher(stream);
//Either[1]
pub
- Publisher to construct an Either fromstatic <ST,T,T2,T3,RT> LazyEither5<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 <ST,T,T2,T3,RT> LazyEither5<ST,T,T2,T3,RT> later(java.util.function.Supplier<LazyEither5<ST,T,T2,T3,RT>> lazy)
static <ST,T,T2,T3,RT> LazyEither5<ST,T,T2,T3,RT> always(java.util.function.Supplier<LazyEither5<ST,T,T2,T3,RT>> lazy)
static <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> rightEval(Eval<RT> right)
right
- Eval to construct Either4#Right fromstatic <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> left1Eval(Eval<LT> left)
left
- Eval to construct Either4#Left1 fromstatic <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> right(RT right)
right
- Value to storestatic <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> left1(LT left)
left
- Value to storestatic <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> left2(M1 middle)
middle
- Value to storestatic <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> left3(B middle)
middle
- Value to storestatic <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> left4(T4 middle)
middle
- Value to storestatic <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> left2Eval(Eval<M1> middle)
middle
- Eval to construct Either4#middle fromstatic <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> left3Eval(Eval<B> middle)
middle
- Eval to construct Either4#middle fromstatic <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> left4Eval(Eval<T4> middle)
middle
- Eval to construct Either4#middle fromstatic <LT,M1,B,T4,RT> LazyEither5<LT,M1,B,T4,RT> foEval(Eval<B> middle)
middle
- Eval to construct Either4#middle fromdefault Trampoline<LazyEither5<LT1,LT2,LT3,LT4,RT>> toTrampoline()
Maybe<RT> filter(java.util.function.Predicate<? super RT> test)
<RT1> LazyEither5<LT1,LT2,LT3,LT4,RT1> flatMap(java.util.function.Function<? super RT,? extends LazyEither5<LT1,LT2,LT3,LT4,? extends RT1>> mapper)
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> LazyEither5<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> LazyEither5<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 Transformable<RT>
fn
- Transformation functiondefault Ior<LT1,RT> toIor()
default <R> LazyEither5<LT1,LT2,LT3,LT4,R> coflatMap(java.util.function.Function<? super LazyEither5<LT1,LT2,LT3,LT4,RT>,R> mapper)
default <T2,R1,R2,R3,R> LazyEither5<LT1,LT2,LT3,LT4,R> forEach4(java.util.function.Function<? super RT,? extends LazyEither5<LT1,LT2,LT3,LT4,R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends LazyEither5<LT1,LT2,LT3,LT4,R2>> value2, Function3<? super RT,? super R1,? super R2,? extends LazyEither5<LT1,LT2,LT3,LT4,R3>> value3, Function4<? super RT,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
default <T2,R1,R2,R> LazyEither5<LT1,LT2,LT3,LT4,R> forEach3(java.util.function.Function<? super RT,? extends LazyEither5<LT1,LT2,LT3,LT4,R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends LazyEither5<LT1,LT2,LT3,LT4,R2>> value2, Function3<? super RT,? super R1,? super R2,? extends R> yieldingFunction)
default <R1,R> LazyEither5<LT1,LT2,LT3,LT4,R> forEach2(java.util.function.Function<? super RT,? extends LazyEither5<LT1,LT2,LT3,LT4,R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends R> yieldingFunction)
default <T2,R> LazyEither5<LT1,LT2,LT3,LT4,R> zip(LazyEither5<LT1,LT2,LT3,LT4,? extends T2> app, java.util.function.BiFunction<? super RT,? super T2,? extends R> fn)
default LazyEither5<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 LazyEither5<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 Transformable