LT1
- Left1 typeLT2
- Left2 typeRT
- Right type (operations are performed on this type if present)public interface LazyEither3<LT1,LT2,RT> extends Value<RT>, OrElseValue<RT,LazyEither3<LT1,LT2,RT>>, Unit<RT>, Transformable<RT>, Filters<RT>, BiTransformable<LT2,RT>, To<LazyEither3<LT1,LT2,RT>>, Sealed3<LT1,LT2,RT>, Higher3<DataWitness.lazyEither3,LT1,LT2,RT>
Modifier and Type | Interface and Description |
---|---|
static class |
LazyEither3.CompletableEither3<ORG,LT1,RT> |
static class |
LazyEither3.Lazy<ST,M,PT> |
static class |
LazyEither3.Left1<ST,M,PT> |
static class |
LazyEither3.Left2<ST,M,PT> |
static class |
LazyEither3.Right<ST,M,PT> |
Modifier and Type | Method and Description |
---|---|
static <LT1,LT2,RT> |
accumulate(Monoid<RT> reducer,
java.lang.Iterable<LazyEither3<LT1,LT2,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,RT> LazyEither3<ST,T,RT> |
always(java.util.function.Supplier<LazyEither3<ST,T,RT>> lazy) |
static <X,LT extends X,M extends X,RT extends X,R> |
applyAny(LazyEither3<LT,M,RT> either) |
<R1,R2> LazyEither3<LT1,R1,R2> |
bimap(java.util.function.Function<? super LT2,? extends R1> fn1,
java.util.function.Function<? super RT,? extends R2> fn2)
Transform this BiTransformable, changing two value types at once.
|
default LazyEither3<LT1,LT2,RT> |
bipeek(java.util.function.Consumer<? super LT2> 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> LazyEither3<LT1,LT2,R> |
coflatMap(java.util.function.Function<? super LazyEither3<LT1,LT2,RT>,R> mapper) |
static <X,LT extends X,M extends X,RT extends X> |
consumeAny(LazyEither3<LT,M,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,RT> LazyEither3.CompletableEither3<RT,LT2,RT> |
either3()
Create a reactive CompletableEither
|
Maybe<RT> |
filter(java.util.function.Predicate<? super RT> test)
Filter this Either3 resulting in a Maybe#none if it is not a Right instance or if the predicate does not
hold.
|
default LazyEither3<LT1,LT2,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.
|
<R2> LazyEither3<LT1,LT2,R2> |
flatMap(java.util.function.Function<? super RT,? extends LazyEither3<LT1,LT2,? extends R2>> mapper)
Flattening transformation on this Either3.
|
<R> R |
fold(java.util.function.Function<? super LT1,? extends R> left1,
java.util.function.Function<? super LT2,? extends R> mid,
java.util.function.Function<? super RT,? extends R> right)
Visit the types in this Either3, only one user supplied function is executed depending on the type
|
static <X,LT extends X,M extends X,RT extends X,R> |
foldAny(LazyEither3<LT,M,RT> either,
java.util.function.Function<? super X,? extends R> fn) |
default <R1,R> LazyEither3<LT1,LT2,R> |
forEach2(java.util.function.Function<? super RT,? extends LazyEither3<LT1,LT2,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 LazyEither3<LT1,LT2,R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,? extends LazyEither3<LT1,LT2,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 LazyEither3<LT1,LT2,R1>> value1,
java.util.function.BiFunction<? super RT,? super R1,? extends LazyEither3<LT1,LT2,R2>> value2,
Function3<? super RT,? super R1,? super R2,? extends LazyEither3<LT1,LT2,R3>> value3,
Function4<? super RT,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
static <LT2,RT> LazyEither3<java.lang.Throwable,LT2,RT> |
fromFuture(Future<RT> future) |
static <ST,T,RT> LazyEither3<ST,T,RT> |
fromIterable(java.lang.Iterable<RT> iterable)
Construct a Right Either3 from the supplied Iterable
|
static <LT1,LT2,RT> |
fromLazy(Eval<LazyEither3<LT1,LT2,RT>> lazy) |
static <T1,T> LazyEither3<java.lang.Throwable,T1,T> |
fromPublisher(org.reactivestreams.Publisher<T> pub)
Lazily construct a Right Either from the supplied publisher
|
Option<RT> |
get() |
boolean |
isLeft1() |
boolean |
isLeft2() |
boolean |
isRight() |
static <ST,T,RT> LazyEither3<ST,T,RT> |
later(java.util.function.Supplier<LazyEither3<ST,T,RT>> lazy) |
static <LT,B,RT> LazyEither3<LT,B,RT> |
left1(LT left)
Construct a Either3#Left1
|
static <LT,B,RT> LazyEither3<LT,B,RT> |
left1Eval(Eval<LT> left)
Construct a Either3#Left1 from an Eval
|
static <LT,B,RT> LazyEither3<LT,B,RT> |
left2(B middle)
Construct a Either3#Left2
|
static <LT,B,RT> LazyEither3<LT,B,RT> |
left2Eval(Eval<B> middle)
Construct a Either3#Left2 from an Eval
|
<R> LazyEither3<LT1,LT2,R> |
map(java.util.function.Function<? super RT,? extends R> fn)
Transform this functor using the supplied transformation function
|
static <L1,L2,T> LazyEither3<L1,L2,T> |
narrowK(Higher<Higher<Higher<DataWitness.lazyEither3,L1>,L2>,T> xor) |
static <L1,L2,T> LazyEither3<L1,L2,T> |
narrowK3(Higher3<DataWitness.lazyEither3,L1,L2,T> xor) |
default LazyEither3<LT1,LT2,LazyEither3<LT1,LT2,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 LazyEither3<LT1,LT2,RT> |
peek(java.util.function.Consumer<? super RT> c)
Peek at the current value of this Transformable, without transforming it
|
static <LT,B,RT> LazyEither3<LT,B,RT> |
right(RT right)
Construct a Either3#Right
|
static <LT,B,RT> LazyEither3<LT,B,RT> |
rightEval(Eval<RT> right)
Construct a Either3#Right from an Eval
|
static <LT1,LT2,PT> |
sequence(java.lang.Iterable<? extends LazyEither3<LT1,LT2,PT>> xors)
Turn an IterableX of Either3 into a single Either with Lists of values.
|
static <L1,L2,T> LazyEither3<L1,L2,ReactiveSeq<T>> |
sequence(ReactiveSeq<? extends LazyEither3<L1,L2,T>> stream) |
LazyEither3<RT,LT2,LT1> |
swap1() |
LazyEither3<LT1,RT,LT2> |
swap2() |
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<LazyEither3<LT1,LT2,RT>> |
toTrampoline() |
static <L1,L2,T,R> |
traverse(java.util.function.Function<? super T,? extends R> fn,
ReactiveSeq<LazyEither3<L1,L2,T>> stream) |
static <LT1,LT2,PT,R> |
traverse(java.lang.Iterable<LazyEither3<LT1,LT2,PT>> xors,
java.util.function.Function<? super PT,? extends R> fn)
Traverse a Collection of Either3 producing an Either3 with a Seq, applying the transformation function to every
element in the list
|
<T> LazyEither3<LT1,LT2,T> |
unit(T unit) |
static <X,LT extends X,M extends X,RT extends X> |
visitAny(java.util.function.Consumer<? super X> c,
LazyEither3<LT,M,RT> either) |
static <X,LT extends X,M extends X,RT extends X,R> |
visitAny(LazyEither3<LT,M,RT> either,
java.util.function.Function<? super X,? extends R> fn)
Deprecated.
|
static <LT1,LT2,T> |
widen(LazyEither3<LT1,LT2,T> narrow) |
default <T2,R> LazyEither3<LT1,LT2,R> |
zip(LazyEither3<LT1,LT2,? extends T2> app,
java.util.function.BiFunction<? super RT,? super T2,? extends R> fn) |
default <T2,R> LazyEither3<LT1,LT2,R> |
zip(org.reactivestreams.Publisher<? 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 <LT1,LT2,T> Higher<Higher<Higher<DataWitness.lazyEither3,LT1>,LT2>,T> widen(LazyEither3<LT1,LT2,T> narrow)
default LazyEither3<LT1,LT2,RT> filter(java.util.function.Predicate<? super RT> test, java.util.function.Function<? super RT,? extends LT1> rightToLeft)
default <T2,R> LazyEither3<LT1,LT2,R> zip(LazyEither3<LT1,LT2,? extends T2> app, java.util.function.BiFunction<? super RT,? super T2,? extends R> fn)
default <T2,R> LazyEither3<LT1,LT2,R> zip(org.reactivestreams.Publisher<? extends T2> app, java.util.function.BiFunction<? super RT,? super T2,? extends R> fn)
static <LT2,RT> LazyEither3.CompletableEither3<RT,LT2,RT> either3()
___Example 1___
CompletableEither<Integer,Integer> completable = Either3.lazyEither3();
Either3<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 = Either3.lazyEither3();
Either3<Throwable,String,Integer> mapped = completable.map(i->i*2)
.flatMap(i->Eval.later(()->i+1));
completable.complete(null);
//Either3:Left3[NoSuchElementException]
___Example 3___
CompletableEither<Integer,Integer> completable = Either3.lazyEither3();
Either3<Throwable,String,Integer> mapped = completable.map(i->i*2)
.flatMap(i->Eval.later(()->i+1));
completable.complete(new IllegalStateException());
//Either:Left[IllegalStateElementException]
RT
- static <LT1,LT2,RT> LazyEither3<LT1,LT2,RT> fromLazy(Eval<LazyEither3<LT1,LT2,RT>> lazy)
static <LT2,RT> LazyEither3<java.lang.Throwable,LT2,RT> fromFuture(Future<RT> future)
static <LT1,LT2,PT> LazyEither3<LT1,LT2,ReactiveSeq<PT>> sequence(java.lang.Iterable<? extends LazyEither3<LT1,LT2,PT>> xors)
Either3<String,String,Integer> just = Either3.right(10);
Either3<String,String,Integer> none = Either3.left("none");
Either3<String,String,ReactiveSeq<Integer>> xors =Either3.sequence(Seq.of(just,none,Either3.right(1)));
//Eitehr.right(ReactiveSeq.of(10,1)));
xors
- Either3 to sequencestatic <L1,L2,T> LazyEither3<L1,L2,ReactiveSeq<T>> sequence(ReactiveSeq<? extends LazyEither3<L1,L2,T>> stream)
static <L1,L2,T,R> LazyEither3<L1,L2,ReactiveSeq<R>> traverse(java.util.function.Function<? super T,? extends R> fn, ReactiveSeq<LazyEither3<L1,L2,T>> stream)
static <LT1,LT2,PT,R> LazyEither3<LT1,LT2,ReactiveSeq<R>> traverse(java.lang.Iterable<LazyEither3<LT1,LT2,PT>> xors, java.util.function.Function<? super PT,? extends R> fn)
xors
- Either3s to sequence and transformfn
- Transformation functionstatic <LT1,LT2,RT> LazyEither3<LT1,LT2,RT> accumulate(Monoid<RT> reducer, java.lang.Iterable<LazyEither3<LT1,LT2,RT>> xors)
com.oath.cyclops.Monoids
.
Either3<String,String,Integer> just = Either3.right(10);
Either3<String,String,Integer> none = Either3.left("none");
Either3<Seq<String>,Seq<String>,Integer> xors = Either3.accumulateRight(Monoids.intSum,Seq.of(just,none,Either3.right(1)));
//Either3.right(11);
xors
- Collection of Eithers to accumulate right valuesreducer
- Reducer to accumulate resultsstatic <T1,T> LazyEither3<java.lang.Throwable,T1,T> fromPublisher(org.reactivestreams.Publisher<T> pub)
ReactiveSeq<Integer> stream = ReactiveSeq.of(1,2,3);
Either3<Throwable,String,Integer> future = Either3.fromPublisher(stream);
//Either[1]
pub
- Publisher to construct an Either fromstatic <ST,T,RT> LazyEither3<ST,T,RT> fromIterable(java.lang.Iterable<RT> iterable)
List<Integer> list = Arrays.asList(1,2,3);
Either3<Throwable,String,Integer> future = Either3.fromIterable(list);
//Either[1]
iterable
- Iterable to construct an Either fromstatic <ST,T,RT> LazyEither3<ST,T,RT> later(java.util.function.Supplier<LazyEither3<ST,T,RT>> lazy)
static <ST,T,RT> LazyEither3<ST,T,RT> always(java.util.function.Supplier<LazyEither3<ST,T,RT>> lazy)
static <X,LT extends X,M extends X,RT extends X> java.util.function.Consumer<java.util.function.Consumer<? super X>> consumeAny(LazyEither3<LT,M,RT> either)
myEither.to(Either3::consumeAny)
.accept(System.out::println);
either
- Either to consume value forstatic <X,LT extends X,M extends X,RT extends X,R> java.util.function.Function<java.util.function.Function<? super X,R>,R> applyAny(LazyEither3<LT,M,RT> either)
@Deprecated static <X,LT extends X,M extends X,RT extends X,R> R visitAny(LazyEither3<LT,M,RT> either, java.util.function.Function<? super X,? extends R> fn)
static <X,LT extends X,M extends X,RT extends X,R> R foldAny(LazyEither3<LT,M,RT> either, java.util.function.Function<? super X,? extends R> fn)
static <X,LT extends X,M extends X,RT extends X> X visitAny(java.util.function.Consumer<? super X> c, LazyEither3<LT,M,RT> either)
static <LT,B,RT> LazyEither3<LT,B,RT> rightEval(Eval<RT> right)
right
- Eval to construct Either3#Right fromstatic <LT,B,RT> LazyEither3<LT,B,RT> left1Eval(Eval<LT> left)
left
- Eval to construct Either3#Left fromstatic <LT,B,RT> LazyEither3<LT,B,RT> right(RT right)
right
- Value to storestatic <LT,B,RT> LazyEither3<LT,B,RT> left1(LT left)
left
- Value to storestatic <LT,B,RT> LazyEither3<LT,B,RT> left2(B middle)
middle
- Value to storestatic <LT,B,RT> LazyEither3<LT,B,RT> left2Eval(Eval<B> middle)
middle
- Eval to construct Either3#middle from<R> R fold(java.util.function.Function<? super LT1,? extends R> left1, java.util.function.Function<? super LT2,? extends R> mid, java.util.function.Function<? super RT,? extends R> right)
Maybe<RT> filter(java.util.function.Predicate<? super RT> test)
<R2> LazyEither3<LT1,LT2,R2> flatMap(java.util.function.Function<? super RT,? extends LazyEither3<LT1,LT2,? extends R2>> mapper)
mapper
- Mapping functionLazyEither3<LT1,RT,LT2> swap2()
LazyEither3<RT,LT2,LT1> swap1()
boolean isRight()
boolean isLeft1()
boolean isLeft2()
default Ior<LT1,RT> toIor()
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 Trampoline<LazyEither3<LT1,LT2,RT>> toTrampoline()
default Maybe<RT> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
default <R> LazyEither3<LT1,LT2,R> coflatMap(java.util.function.Function<? super LazyEither3<LT1,LT2,RT>,R> mapper)
default LazyEither3<LT1,LT2,LazyEither3<LT1,LT2,RT>> nest()
default <T2,R1,R2,R3,R> LazyEither3<LT1,LT2,R> forEach4(java.util.function.Function<? super RT,? extends LazyEither3<LT1,LT2,R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends LazyEither3<LT1,LT2,R2>> value2, Function3<? super RT,? super R1,? super R2,? extends LazyEither3<LT1,LT2,R3>> value3, Function4<? super RT,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
default <T2,R1,R2,R> LazyEither3<LT1,LT2,R> forEach3(java.util.function.Function<? super RT,? extends LazyEither3<LT1,LT2,R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends LazyEither3<LT1,LT2,R2>> value2, Function3<? super RT,? super R1,? super R2,? extends R> yieldingFunction)
default <R1,R> LazyEither3<LT1,LT2,R> forEach2(java.util.function.Function<? super RT,? extends LazyEither3<LT1,LT2,R1>> value1, java.util.function.BiFunction<? super RT,? super R1,? extends R> yieldingFunction)
<R1,R2> LazyEither3<LT1,R1,R2> bimap(java.util.function.Function<? super LT2,? 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<LT2,RT>
fn1
- transformation function for the first typefn2
- transformation function for the second type<R> LazyEither3<LT1,LT2,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 LazyEither3<LT1,LT2,RT> bipeek(java.util.function.Consumer<? super LT2> 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<LT2,RT>
c1
- consumer for the first typec2
- consumer for the second typedefault LazyEither3<LT1,LT2,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 Transformablestatic <L1,L2,T> LazyEither3<L1,L2,T> narrowK3(Higher3<DataWitness.lazyEither3,L1,L2,T> xor)
static <L1,L2,T> LazyEither3<L1,L2,T> narrowK(Higher<Higher<Higher<DataWitness.lazyEither3,L1>,L2>,T> xor)