ST
- Left typePT
- Right typepublic interface Either<ST,PT>
extends com.aol.cyclops.control.Xor<ST,PT>
public class Member{ Eitherteam; } Rather than public class Member{
Modifier and Type | Interface and Description |
---|---|
static class |
Either.Lazy<ST,PT> |
static class |
Either.Left<ST,PT> |
static class |
Either.Right<ST,PT> |
com.aol.cyclops.control.Xor.Primary<ST,PT>, com.aol.cyclops.control.Xor.Secondary<ST,PT>
com.aol.cyclops.types.applicative.ApplicativeFunctor.Applicatives, com.aol.cyclops.types.applicative.ApplicativeFunctor.ApplyFunctions<T>
Modifier and Type | Method and Description |
---|---|
static <LT1,RT> Either<com.aol.cyclops.data.collections.extensions.standard.ListX<LT1>,RT> |
accumulate(com.aol.cyclops.Monoid<RT> reducer,
com.aol.cyclops.data.collections.extensions.CollectionX<Either<LT1,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)
Monoids . |
default com.aol.cyclops.types.anyM.AnyMValue<PT> |
anyM() |
static <LT1,T> com.aol.cyclops.types.anyM.AnyMValue<T> |
anyM(Either<LT1,T> xor)
Create an AnyMValue instance that wraps an Either3
|
static <ST,T> com.aol.cyclops.data.collections.extensions.standard.ListX<com.aol.cyclops.types.anyM.AnyMValue<T>> |
anyMList(java.lang.Iterable<Either<ST,T>> anyM)
Take an iterable containing Either3s and convert them into a List of AnyMs
e.g.
|
static <X,LT extends X,M extends X,RT extends X,R> |
applyAny(Either<LT,RT> either) |
default <U1,U2> Either<U1,U2> |
bicast(java.lang.Class<U1> type1,
java.lang.Class<U2> type2) |
default <R1,R2> Either<R1,R2> |
bimap(java.util.function.Function<? super ST,? extends R1> secondary,
java.util.function.Function<? super PT,? extends R2> primary) |
default Either<ST,PT> |
bipeek(java.util.function.Consumer<? super ST> c1,
java.util.function.Consumer<? super PT> c2) |
default <R1,R2> Either<R1,R2> |
bitrampoline(java.util.function.Function<? super ST,? extends com.aol.cyclops.control.Trampoline<? extends R1>> mapper1,
java.util.function.Function<? super PT,? extends com.aol.cyclops.control.Trampoline<? extends R2>> mapper2) |
default <U> Either<ST,U> |
cast(java.lang.Class<? extends U> type) |
default <R> Either<ST,R> |
coflatMap(java.util.function.Function<? super com.aol.cyclops.types.MonadicValue<PT>,R> mapper) |
default Either<ST,PT> |
combine(java.util.function.BinaryOperator<com.aol.cyclops.types.Combiner<PT>> combiner,
com.aol.cyclops.types.Combiner<PT> app) |
default <T2,R> Either<ST,R> |
combine(Either<? extends ST,? extends T2> app,
java.util.function.BinaryOperator<ST> semigroup,
java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
Accumulate secondary values with the provided BinaryOperator / Semigroup
Semigroups
Right accumulation only occurs if all phases are primary |
<T2,R> Either<ST,R> |
combine(com.aol.cyclops.types.Value<? extends T2> app,
java.util.function.BiFunction<? super PT,? super T2,? extends R> fn) |
default <T2,R> Either<ST,R> |
combine(com.aol.cyclops.control.Xor<? extends ST,? extends T2> app,
java.util.function.BinaryOperator<ST> semigroup,
java.util.function.BiFunction<? super PT,? super T2,? extends R> fn) |
default Either<ST,PT> |
combineEager(com.aol.cyclops.Monoid<PT> monoid,
com.aol.cyclops.types.MonadicValue<? extends PT> v2) |
default <T2,R> Either<com.aol.cyclops.data.collections.extensions.persistent.PStackX<ST>,R> |
combineToList(Either<ST,? extends T2> app,
java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
Accumulate secondarys into a PStackX (extended Persistent List) and Right with the supplied combiner function
Right accumulation only occurs if all phases are primary
|
default <T2,R> Either<com.aol.cyclops.data.collections.extensions.persistent.PStackX<ST>,R> |
combineToList(com.aol.cyclops.control.Xor<ST,? extends T2> app,
java.util.function.BiFunction<? super PT,? super T2,? extends R> fn) |
static <X,LT extends X,M extends X,RT extends X> |
consumeAny(Either<LT,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)
|
Either<ST,PT> |
filter(java.util.function.Predicate<? super PT> test) |
default Either<ST,PT> |
filterNot(java.util.function.Predicate<? super PT> fn) |
<RT1> Either<ST,RT1> |
flatMap(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<? extends RT1>> mapper) |
default <R> Either<ST,R> |
flatMapIterable(java.util.function.Function<? super PT,? extends java.lang.Iterable<? extends R>> mapper) |
default <R> Either<ST,R> |
flatMapPublisher(java.util.function.Function<? super PT,? extends org.reactivestreams.Publisher<? extends R>> mapper) |
default <R1,R> Either<ST,R> |
forEach2(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1,
java.util.function.BiFunction<? super PT,? super R1,? extends R> yieldingFunction) |
default <R1,R> Either<ST,R> |
forEach2(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1,
java.util.function.BiFunction<? super PT,? super R1,java.lang.Boolean> filterFunction,
java.util.function.BiFunction<? super PT,? super R1,? extends R> yieldingFunction) |
default <T2,R1,R2,R> |
forEach3(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1,
java.util.function.BiFunction<? super PT,? super R1,? extends com.aol.cyclops.types.MonadicValue<R2>> value2,
com.aol.cyclops.util.function.TriFunction<? super PT,? super R1,? super R2,? extends R> yieldingFunction) |
default <T2,R1,R2,R> |
forEach3(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1,
java.util.function.BiFunction<? super PT,? super R1,? extends com.aol.cyclops.types.MonadicValue<R2>> value2,
com.aol.cyclops.util.function.TriFunction<? super PT,? super R1,? super R2,java.lang.Boolean> filterFunction,
com.aol.cyclops.util.function.TriFunction<? super PT,? super R1,? super R2,? extends R> yieldingFunction) |
default <T2,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1,
java.util.function.BiFunction<? super PT,? super R1,? extends com.aol.cyclops.types.MonadicValue<R2>> value2,
com.aol.cyclops.util.function.TriFunction<? super PT,? super R1,? super R2,? extends com.aol.cyclops.types.MonadicValue<R3>> value3,
com.aol.cyclops.util.function.QuadFunction<? super PT,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
default <T2,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1,
java.util.function.BiFunction<? super PT,? super R1,? extends com.aol.cyclops.types.MonadicValue<R2>> value2,
com.aol.cyclops.util.function.TriFunction<? super PT,? super R1,? super R2,? extends com.aol.cyclops.types.MonadicValue<R3>> value3,
com.aol.cyclops.util.function.QuadFunction<? super PT,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction,
com.aol.cyclops.util.function.QuadFunction<? super PT,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
static <ST,T> Either<ST,T> |
fromIterable(java.lang.Iterable<T> iterable)
Construct a Right Either from the supplied Iterable
|
static <LT1,RT> Either<LT1,RT> |
fromMonadicValue(com.aol.cyclops.types.MonadicValue<RT> mv2) |
static <T> Either<java.lang.Throwable,T> |
fromPublisher(org.reactivestreams.Publisher<T> pub)
Lazily construct a Right Either from the supplied publisher
|
PT |
get() |
boolean |
isLeft() |
default boolean |
isPresent() |
default boolean |
isPrimary() |
boolean |
isRight() |
default boolean |
isSecondary() |
static <ST,PT> Either<ST,PT> |
left(ST value)
Create an instance of the secondary type.
|
static <LT,B,RT> Either<LT,RT> |
leftEval(com.aol.cyclops.control.Eval<LT> left) |
default Either<com.aol.cyclops.data.collections.extensions.persistent.PStackX<ST>,PT> |
list() |
<R> Either<ST,R> |
map(java.util.function.Function<? super PT,? extends R> fn) |
default <R1,R2> Either<R1,R2> |
mapBoth(java.util.function.Function<? super ST,? extends R1> secondary,
java.util.function.Function<? super PT,? extends R2> primary)
Deprecated.
|
<R> com.aol.cyclops.control.Eval<R> |
matches(java.util.function.Function<com.aol.cyclops.control.Matchable.CheckValue1<ST,R>,com.aol.cyclops.control.Matchable.CheckValue1<ST,R>> fn1,
java.util.function.Function<com.aol.cyclops.control.Matchable.CheckValue1<PT,R>,com.aol.cyclops.control.Matchable.CheckValue1<PT,R>> fn2,
java.util.function.Supplier<? extends R> otherwise)
Pattern match on the value/s inside this Either.
|
static <ST,PT> Either<ST,PT> |
narrow(Either<? extends ST,? extends PT> broad) |
default Either<ST,com.aol.cyclops.types.MonadicValue<PT>> |
nest() |
default Either<ST,PT> |
notNull() |
default <U> Either<ST,U> |
ofType(java.lang.Class<? extends U> type) |
default <R> Either<ST,R> |
patternMatch(java.util.function.Function<com.aol.cyclops.control.Matchable.CheckValue1<PT,R>,com.aol.cyclops.control.Matchable.CheckValue1<PT,R>> case1,
java.util.function.Supplier<? extends R> otherwise) |
Either<ST,PT> |
peek(java.util.function.Consumer<? super PT> action) |
void |
peek(java.util.function.Consumer<? super ST> stAction,
java.util.function.Consumer<? super PT> ptAction)
Deprecated.
|
static <ST,PT> Either<ST,PT> |
right(PT value)
Create an instance of the primary type.
|
static <LT,B,RT> Either<LT,RT> |
rightEval(com.aol.cyclops.control.Eval<RT> right) |
<LT1> Either<LT1,PT> |
secondaryFlatMap(java.util.function.Function<? super ST,? extends com.aol.cyclops.control.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 com.aol.cyclops.control.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
|
com.aol.cyclops.control.ReactiveSeq<ST> |
secondaryToStream() |
com.aol.cyclops.types.Value<ST> |
secondaryValue() |
static <LT1,PT> Either<com.aol.cyclops.data.collections.extensions.standard.ListX<LT1>,com.aol.cyclops.data.collections.extensions.standard.ListX<PT>> |
sequence(com.aol.cyclops.data.collections.extensions.CollectionX<Either<LT1,PT>> xors)
Turn a collection of Eithers into a single Either with Lists of values.
|
Either<PT,ST> |
swap()
Swap types so operations directly affect the current (pre-swap) Left type
|
com.aol.cyclops.control.Ior<ST,PT> |
toIor() |
default java.util.Optional<PT> |
toOptional() |
default com.aol.cyclops.control.Xor<ST,PT> |
toXor() |
default <ST2> com.aol.cyclops.control.Xor<ST2,PT> |
toXor(ST2 secondary) |
default <R> Either<ST,R> |
trampoline(java.util.function.Function<? super PT,? extends com.aol.cyclops.control.Trampoline<? extends R>> mapper) |
static <LT1,PT,R> Either<com.aol.cyclops.data.collections.extensions.standard.ListX<LT1>,com.aol.cyclops.data.collections.extensions.standard.ListX<R>> |
traverse(com.aol.cyclops.data.collections.extensions.CollectionX<Either<LT1,PT>> xors,
java.util.function.Function<? super PT,? extends R> fn)
Traverse a Collection of Either producting an Either3 with a ListX, applying the transformation function to every
element in the list
|
default <T> Either<ST,T> |
unit(T unit) |
<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.
|
static <X,LT extends X,RT extends X> |
visitAny(java.util.function.Consumer<? super X> c,
Either<LT,RT> either) |
static <X,PT extends X,ST extends X,R> |
visitAny(Either<ST,PT> either,
java.util.function.Function<? super X,? extends R> fn) |
default <T2,R> Either<ST,R> |
zip(java.util.function.BiFunction<? super PT,? super T2,? extends R> fn,
org.reactivestreams.Publisher<? extends T2> app) |
default <T2,R> Either<ST,R> |
zip(java.lang.Iterable<? extends T2> app,
java.util.function.BiFunction<? super PT,? super T2,? extends R> fn) |
default <U> Either<ST,org.jooq.lambda.tuple.Tuple2<PT,U>> |
zip(java.lang.Iterable<? extends U> other) |
default <U> Either<ST,org.jooq.lambda.tuple.Tuple2<PT,U>> |
zip(org.jooq.lambda.Seq<? extends U> other) |
default <U,R> Either<ST,R> |
zip(org.jooq.lambda.Seq<? extends U> other,
java.util.function.BiFunction<? super PT,? super U,? extends R> zipper) |
default <U> Either<ST,org.jooq.lambda.tuple.Tuple2<PT,U>> |
zip(java.util.stream.Stream<? extends U> other) |
default <U,R> Either<ST,R> |
zip(java.util.stream.Stream<? extends U> other,
java.util.function.BiFunction<? super PT,? super U,? extends R> zipper) |
accumulatePrimary, accumulatePrimary, accumulatePrimary, accumulateSecondary, accumulateSecondary, accumulateSecondary, primary, secondary, sequencePrimary, sequenceSecondary
applyFunctions
collect, fold, fold, generate, iterate, iterator, mapReduce, mkString, newSubscriber, of, stream, subscribe, test, toDequeX, toEvalAlways, toEvalLater, toEvalNow, toFeatureToggle, toFutureStream, toFutureStream, toLazyImmutable, toList, toListX, toMaybe, toMutable, toPBagX, toPOrderedSetX, toPQueueX, toPSetX, toPStackX, toPVectorX, toQueueX, toSetX, toSimpleReact, toSimpleReact, toSortedSetX, toTry, toTry, toTry, unapply
endsWith, endsWithIterable, findAny, findFirst, firstValue, foldable, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, join, join, join, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce, schedule, scheduleFixedDelay, scheduleFixedRate, single, single, singleOptional, startsWith, startsWithIterable, toConcurrentLazyCollection, toConcurrentLazyStreamable, toLazyCollection, validate, xMatch
static <LT1,RT> Either<LT1,RT> fromMonadicValue(com.aol.cyclops.types.MonadicValue<RT> mv2)
static <LT1,T> com.aol.cyclops.types.anyM.AnyMValue<T> anyM(Either<LT1,T> xor)
xor
- Xor to wrap inside an AnyMstatic <ST,T> com.aol.cyclops.data.collections.extensions.standard.ListX<com.aol.cyclops.types.anyM.AnyMValue<T>> anyMList(java.lang.Iterable<Either<ST,T>> anyM)
List<AnyM<Integer>> anyMs = anyMList(Arrays.asList(Either.right(1),Either.left(10));
//List[AnyM[Either.right[1],Either:left[10]]]
anyM
- Iterable containing Eithersstatic <LT1,PT> Either<com.aol.cyclops.data.collections.extensions.standard.ListX<LT1>,com.aol.cyclops.data.collections.extensions.standard.ListX<PT>> sequence(com.aol.cyclops.data.collections.extensions.CollectionX<Either<LT1,PT>> xors)
Either<String,Integer> just = Either.right(10);
Either<String,Integer> none = Either.left("none");
Either<ListX<String>,ListX<Integer>> xors =Either.sequence(ListX.of(just,none,Either.right(1)));
//Eitehr.right(ListX.of(10,1)));
Either
- Either to sequencestatic <LT1,PT,R> Either<com.aol.cyclops.data.collections.extensions.standard.ListX<LT1>,com.aol.cyclops.data.collections.extensions.standard.ListX<R>> traverse(com.aol.cyclops.data.collections.extensions.CollectionX<Either<LT1,PT>> xors, java.util.function.Function<? super PT,? extends R> fn)
xors
- Eithers to sequence and transformfn
- Transformation functionstatic <LT1,RT> Either<com.aol.cyclops.data.collections.extensions.standard.ListX<LT1>,RT> accumulate(com.aol.cyclops.Monoid<RT> reducer, com.aol.cyclops.data.collections.extensions.CollectionX<Either<LT1,RT>> xors)
Monoids
.
Either3<String,String,Integer> just = Either3.right(10);
Either3<String,String,Integer> none = Either3.left("none");
Either3<ListX<String>,ListX<String>,Integer> xors = Either3.accumulatePrimary(Monoids.intSum,ListX.of(just,none,Either3.right(1)));
//Either3.right(11);
xors
- Collection of Eithers to accumulate primary valuesreducer
- Reducer to accumulate resultsstatic <LT,B,RT> Either<LT,RT> rightEval(com.aol.cyclops.control.Eval<RT> right)
static <LT,B,RT> Either<LT,RT> leftEval(com.aol.cyclops.control.Eval<LT> left)
static <X,LT extends X,M extends X,RT extends X> java.util.function.Consumer<java.util.function.Consumer<? super X>> consumeAny(Either<LT,RT> either)
myEither.to(Either::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(Either<LT,RT> either)
static <X,PT extends X,ST extends X,R> R visitAny(Either<ST,PT> either, java.util.function.Function<? super X,? extends R> fn)
static <X,LT extends X,RT extends X> X visitAny(java.util.function.Consumer<? super X> c, Either<LT,RT> either)
default <T2,R1,R2,R3,R> Either<ST,R> forEach4(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1, java.util.function.BiFunction<? super PT,? super R1,? extends com.aol.cyclops.types.MonadicValue<R2>> value2, com.aol.cyclops.util.function.TriFunction<? super PT,? super R1,? super R2,? extends com.aol.cyclops.types.MonadicValue<R3>> value3, com.aol.cyclops.util.function.QuadFunction<? super PT,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
default <T2,R1,R2,R3,R> Either<ST,R> forEach4(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1, java.util.function.BiFunction<? super PT,? super R1,? extends com.aol.cyclops.types.MonadicValue<R2>> value2, com.aol.cyclops.util.function.TriFunction<? super PT,? super R1,? super R2,? extends com.aol.cyclops.types.MonadicValue<R3>> value3, com.aol.cyclops.util.function.QuadFunction<? super PT,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction, com.aol.cyclops.util.function.QuadFunction<? super PT,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
default <T2,R1,R2,R> Either<ST,R> forEach3(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1, java.util.function.BiFunction<? super PT,? super R1,? extends com.aol.cyclops.types.MonadicValue<R2>> value2, com.aol.cyclops.util.function.TriFunction<? super PT,? super R1,? super R2,? extends R> yieldingFunction)
default <T2,R1,R2,R> Either<ST,R> forEach3(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1, java.util.function.BiFunction<? super PT,? super R1,? extends com.aol.cyclops.types.MonadicValue<R2>> value2, com.aol.cyclops.util.function.TriFunction<? super PT,? super R1,? super R2,java.lang.Boolean> filterFunction, com.aol.cyclops.util.function.TriFunction<? super PT,? super R1,? super R2,? extends R> yieldingFunction)
default <R1,R> Either<ST,R> forEach2(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1, java.util.function.BiFunction<? super PT,? super R1,? extends R> yieldingFunction)
default <R1,R> Either<ST,R> forEach2(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<R1>> value1, java.util.function.BiFunction<? super PT,? super R1,java.lang.Boolean> filterFunction, java.util.function.BiFunction<? super PT,? super R1,? extends R> yieldingFunction)
default <T2,R> Either<com.aol.cyclops.data.collections.extensions.persistent.PStackX<ST>,R> combineToList(com.aol.cyclops.control.Xor<ST,? extends T2> app, java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
default <T2,R> Either<ST,R> combine(com.aol.cyclops.control.Xor<? extends ST,? extends T2> app, java.util.function.BinaryOperator<ST> semigroup, java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
static <T> Either<java.lang.Throwable,T> fromPublisher(org.reactivestreams.Publisher<T> pub)
ReactiveSeq<Integer> stream = ReactiveSeq.of(1,2,3);
Either<Throwable,Integer> future = Either.fromPublisher(stream);
//Either[1]
static <ST,T> Either<ST,T> fromIterable(java.lang.Iterable<T> iterable)
List<Integer> list = Arrays.asList(1,2,3);
Either<Throwable,Integer> future = Either.fromIterable(list);
//Either[1]
static <ST,PT> Either<ST,PT> left(ST value)
Either.<Integer,Integer>left(10).map(i->i+1);
//Either.left[10]
Either.<Integer,Integer>left(10).swap().map(i->i+1);
//Either.right[11]
value
- to wrapstatic <ST,PT> Either<ST,PT> right(PT value)
Either.<Integer,Integer>right(10).map(i->i+1);
//Either.right[11]
value
- To construct an Either fromdefault com.aol.cyclops.types.anyM.AnyMValue<PT> anyM()
default Either<ST,PT> combine(java.util.function.BinaryOperator<com.aol.cyclops.types.Combiner<PT>> combiner, com.aol.cyclops.types.Combiner<PT> app)
default <R> Either<ST,R> flatMapIterable(java.util.function.Function<? super PT,? extends java.lang.Iterable<? extends R>> mapper)
default <R> Either<ST,R> flatMapPublisher(java.util.function.Function<? super PT,? extends org.reactivestreams.Publisher<? extends R>> mapper)
default <R> Either<ST,R> coflatMap(java.util.function.Function<? super com.aol.cyclops.types.MonadicValue<PT>,R> mapper)
default Either<ST,PT> combineEager(com.aol.cyclops.Monoid<PT> monoid, com.aol.cyclops.types.MonadicValue<? extends PT> v2)
default java.util.Optional<PT> toOptional()
Either<ST,PT> secondaryToPrimayMap(java.util.function.Function<? super ST,? extends PT> fn)
<R> Either<R,PT> secondaryMap(java.util.function.Function<? super ST,? extends R> fn)
Either<ST,PT> secondaryPeek(java.util.function.Consumer<? super ST> action)
Either<PT,ST> swap()
Either.left("hello")
.map(v->v+" world")
//Either.seconary["hello"]
Either.left("hello")
.swap()
.map(v->v+" world")
.swap()
//Either.seconary["hello world"]
default boolean isPresent()
default <ST2> com.aol.cyclops.control.Xor<ST2,PT> toXor(ST2 secondary)
default boolean isSecondary()
default boolean isPrimary()
<R> R visit(java.util.function.Function<? super ST,? extends R> secondary, java.util.function.Function<? super PT,? extends R> primary)
Either.right(10)
.visit(secondary->"no", primary->"yes")
//Either["yes"]
Either.left(90)
.visit(secondary->"no", primary->"yes")
//Either["no"]
visit
in interface com.aol.cyclops.control.Xor<ST,PT>
secondary
- Function to execute if this is a Left Eitherprimary
- Function to execute if this is a Right Iorboth
- Function to execute if this Ior contains both types@Deprecated default <R1,R2> Either<R1,R2> mapBoth(java.util.function.Function<? super ST,? extends R1> secondary, java.util.function.Function<? super PT,? extends R2> primary)
default <R1,R2> Either<R1,R2> bimap(java.util.function.Function<? super ST,? extends R1> secondary, java.util.function.Function<? super PT,? extends R2> primary)
default Either<ST,PT> bipeek(java.util.function.Consumer<? super ST> c1, java.util.function.Consumer<? super PT> c2)
default <U1,U2> Either<U1,U2> bicast(java.lang.Class<U1> type1, java.lang.Class<U2> type2)
default <R1,R2> Either<R1,R2> bitrampoline(java.util.function.Function<? super ST,? extends com.aol.cyclops.control.Trampoline<? extends R1>> mapper1, java.util.function.Function<? super PT,? extends com.aol.cyclops.control.Trampoline<? extends R2>> mapper2)
default <R> Either<ST,R> patternMatch(java.util.function.Function<com.aol.cyclops.control.Matchable.CheckValue1<PT,R>,com.aol.cyclops.control.Matchable.CheckValue1<PT,R>> case1, java.util.function.Supplier<? extends R> otherwise)
<R> com.aol.cyclops.control.Eval<R> matches(java.util.function.Function<com.aol.cyclops.control.Matchable.CheckValue1<ST,R>,com.aol.cyclops.control.Matchable.CheckValue1<ST,R>> fn1, java.util.function.Function<com.aol.cyclops.control.Matchable.CheckValue1<PT,R>,com.aol.cyclops.control.Matchable.CheckValue1<PT,R>> fn2, java.util.function.Supplier<? extends R> otherwise)
import static com.aol.cyclops.control.Matchable.otherwise;
import static com.aol.cyclops.control.Matchable.then;
import static com.aol.cyclops.control.Matchable.when;
import static com.aol.cyclops.util.function.Predicates.instanceOf;
Either.right(10)
.matches(c->c.is(when("10"),then("hello")),
c->c.is(when(instanceOf(Integer.class)), then("error")),
otherwise("miss"))
.get()
//"error" Note the second case, 'primary' case is the one that matches
matches
in interface com.aol.cyclops.control.Xor<ST,PT>
fn1
- Pattern matching function executed if this Either has the secondary typefn2
- Pattern matching function executed if this Either has the primary typeotherwise
- Supplier used to provide a value if the selecting pattern matching function fails to find a matchPT get()
com.aol.cyclops.types.Value<ST> secondaryValue()
ST secondaryGet()
java.util.Optional<ST> secondaryToOptional()
com.aol.cyclops.control.ReactiveSeq<ST> secondaryToStream()
<RT1> Either<ST,RT1> flatMap(java.util.function.Function<? super PT,? extends com.aol.cyclops.types.MonadicValue<? extends RT1>> mapper)
<LT1> Either<LT1,PT> secondaryFlatMap(java.util.function.Function<? super ST,? extends com.aol.cyclops.control.Xor<LT1,PT>> mapper)
Either<ST,PT> secondaryToPrimayFlatMap(java.util.function.Function<? super ST,? extends com.aol.cyclops.control.Xor<ST,PT>> fn)
@Deprecated void peek(java.util.function.Consumer<? super ST> stAction, java.util.function.Consumer<? super PT> ptAction)
boolean isRight()
boolean isLeft()
<T2,R> Either<ST,R> combine(com.aol.cyclops.types.Value<? extends T2> app, java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
default <T2,R> Either<com.aol.cyclops.data.collections.extensions.persistent.PStackX<ST>,R> combineToList(Either<ST,? extends T2> app, java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
app
- Value to combine withfn
- Combiner function for primary valuesdefault <T2,R> Either<ST,R> combine(Either<? extends ST,? extends T2> app, java.util.function.BinaryOperator<ST> semigroup, java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
Semigroups
Right accumulation only occurs if all phases are primary
Either<String,String> fail1 = Either.left("failed1");
Either<PStackX<String>,String> result = fail1.list().combine(Either.left("failed2").list(), Semigroups.collectionConcat(),(a,b)->a+b);
//Left of [PStackX.of("failed1","failed2")))]
app
- Value to combine withsemigroup
- to combine secondary typesfn
- To combine primary typesdefault <T2,R> Either<ST,R> zip(java.lang.Iterable<? extends T2> app, java.util.function.BiFunction<? super PT,? super T2,? extends R> fn)
default <T2,R> Either<ST,R> zip(java.util.function.BiFunction<? super PT,? super T2,? extends R> fn, org.reactivestreams.Publisher<? extends T2> app)
default <U,R> Either<ST,R> zip(org.jooq.lambda.Seq<? extends U> other, java.util.function.BiFunction<? super PT,? super U,? extends R> zipper)
default <U,R> Either<ST,R> zip(java.util.stream.Stream<? extends U> other, java.util.function.BiFunction<? super PT,? super U,? extends R> zipper)
default <U> Either<ST,org.jooq.lambda.tuple.Tuple2<PT,U>> zip(java.util.stream.Stream<? extends U> other)
default <U> Either<ST,org.jooq.lambda.tuple.Tuple2<PT,U>> zip(org.jooq.lambda.Seq<? extends U> other)
default <U> Either<ST,org.jooq.lambda.tuple.Tuple2<PT,U>> zip(java.lang.Iterable<? extends U> other)
default <R> Either<ST,R> trampoline(java.util.function.Function<? super PT,? extends com.aol.cyclops.control.Trampoline<? extends R>> mapper)