ST - Secondary typePT - Primary typepublic interface Ior<ST,PT> extends java.util.function.Supplier<PT>, MonadicValue2<ST,PT>, BiFunctor<ST,PT>, Functor<PT>, Filterable<PT>, Applicativable<PT>
| Modifier and Type | Interface and Description |
|---|---|
static class |
Ior.Both<ST,PT> |
static class |
Ior.Primary<ST,PT> |
static class |
Ior.Secondary<ST,PT> |
Applicativable.Applicatives, Applicativable.SemigroupApplyer<T>Value.ValueImpl<T>Convertable.SupplierToConvertable<T>| Modifier and Type | Method and Description |
|---|---|
static <ST,PT,R> Ior<?,R> |
accumulatePrimary(CollectionX<Ior<ST,PT>> iors,
java.util.function.Function<? super PT,R> mapper,
Semigroup<R> reducer) |
static <ST,PT,R> Ior<?,R> |
accumulatePrimary(CollectionX<Ior<ST,PT>> iors,
Reducer<R> reducer) |
static <ST,PT> Ior<?,PT> |
accumulatePrimary(CollectionX<Ior<ST,PT>> iors,
Semigroup<PT> reducer) |
static <ST,PT,R> Ior<?,R> |
accumulateSecondary(CollectionX<Ior<ST,PT>> iors,
java.util.function.Function<? super ST,R> mapper,
Semigroup<R> reducer) |
static <ST,PT,R> Ior<?,R> |
accumulateSecondary(CollectionX<Ior<ST,PT>> iors,
Reducer<R> reducer) |
static <ST,PT> Ior<?,ST> |
accumulateSecondary(CollectionX<Ior<ST,PT>> iors,
Semigroup<ST> reducer) |
default AnyMValue<PT> |
anyM() |
default <U1,U2> Ior<U1,U2> |
bicast(java.lang.Class<U1> type1,
java.lang.Class<U2> type2)
Cast all elements in a stream to a given type, possibly throwing a
ClassCastException. |
default <R1,R2> Ior<R1,R2> |
bimap(java.util.function.Function<? super ST,? extends R1> fn1,
java.util.function.Function<? super PT,? extends R2> fn2) |
default Ior<ST,PT> |
bipeek(java.util.function.Consumer<? super ST> c1,
java.util.function.Consumer<? super PT> c2) |
default <R1,R2> Ior<R1,R2> |
bitrampoline(java.util.function.Function<? super ST,? extends Trampoline<? extends R1>> mapper1,
java.util.function.Function<? super PT,? extends Trampoline<? extends R2>> mapper2)
Performs a map operation that can call a recursive method without running out of stack space
|
java.util.Optional<org.jooq.lambda.tuple.Tuple2<ST,PT>> |
both() |
static <ST,PT> Ior<ST,PT> |
both(Ior<ST,PT> secondary,
Ior<ST,PT> primary) |
static <ST,PT> Ior<ST,PT> |
both(ST secondary,
PT primary) |
default Value<java.util.Optional<org.jooq.lambda.tuple.Tuple2<ST,PT>>> |
bothValue() |
default <U> Ior<ST,U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a stream to a given type, possibly throwing a
ClassCastException. |
default <R> Ior<ST,R> |
coflatMap(java.util.function.Function<? super MonadicValue<PT>,R> mapper) |
default Ior<ST,PT> |
combine(Monoid<PT> monoid,
MonadicValue2<? extends ST,? extends PT> v2)
Eagerly combine two MonadicValues using the supplied monoid
|
Ior<ST,PT> |
filter(java.util.function.Predicate<? super PT> test)
Keep only elements for which the supplied predicates hold
e.g.
|
default Ior<ST,PT> |
filterNot(java.util.function.Predicate<? super PT> fn)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
<LT1,RT1> Ior<LT1,RT1> |
flatMap(java.util.function.Function<? super PT,? extends MonadicValue2<? extends LT1,? extends RT1>> mapper) |
PT |
get() |
boolean |
isBoth() |
boolean |
isPrimary() |
boolean |
isSecondary() |
<R> Ior<ST,R> |
map(java.util.function.Function<? super PT,? extends R> fn)
Transform this functor using the supplied transformation function
|
<R> Eval<R> |
matches(java.util.function.Function<Matchable.CheckValue1<ST,R>,Matchable.CheckValue1<ST,R>> secondary,
java.util.function.Function<Matchable.CheckValue1<PT,R>,Matchable.CheckValue1<PT,R>> primary,
java.util.function.Function<Matchable.CheckValue2<ST,PT,R>,Matchable.CheckValue2<ST,PT,R>> both,
java.util.function.Supplier<? extends R> otherwise) |
default Ior<ST,MonadicValue<PT>> |
nest() |
default Ior<ST,PT> |
notNull()
Filter elements retaining only values which are not null
|
default <U> Ior<ST,U> |
ofType(java.lang.Class<? extends U> type)
Keep only those elements in a stream that are of a given type.
|
default <R> Xor<ST,R> |
patternMatch(java.util.function.Function<Matchable.CheckValue1<PT,R>,Matchable.CheckValue1<PT,R>> case1,
java.util.function.Supplier<? extends R> otherwise)
Transform the elements of this Stream with a Pattern Matching case and default value
|
Ior<ST,PT> |
peek(java.util.function.Consumer<? super PT> action)
Peek at the current value of this Functor, without transforming it
|
static <ST,PT> Ior<ST,PT> |
primary(PT primary) |
static <ST,PT> Ior<ST,PT> |
secondary(ST secondary) |
<LT1,RT1> Ior<LT1,RT1> |
secondaryFlatMap(java.util.function.Function<? super ST,? extends Ior<LT1,RT1>> mapper) |
ST |
secondaryGet() |
<R> Ior<R,PT> |
secondaryMap(java.util.function.Function<? super ST,? extends R> fn) |
Ior<ST,PT> |
secondaryPeek(java.util.function.Consumer<? super ST> action) |
java.util.Optional<ST> |
secondaryToOptional() |
Ior<ST,PT> |
secondaryToPrimayFlatMap(java.util.function.Function<? super ST,? extends Ior<ST,PT>> fn) |
Ior<ST,PT> |
secondaryToPrimayMap(java.util.function.Function<? super ST,? extends PT> fn) |
ReactiveSeq<ST> |
secondaryToStream() |
Value<ST> |
secondaryValue() |
static <ST,PT> Ior<ListX<ST>,ListX<PT>> |
sequencePrimary(CollectionX<Ior<ST,PT>> iors) |
static <ST,PT> Ior<ListX<PT>,ListX<ST>> |
sequenceSecondary(CollectionX<Ior<ST,PT>> iors) |
Ior<PT,ST> |
swap() |
default Ior<ST,PT> |
toIor() |
Xor<ST,PT> |
toXor() |
default <ST2> Xor<ST2,PT> |
toXor(ST2 secondary)
Convert to an Xor where the secondary value will be used if no primary value is present
|
Xor<ST,PT> |
toXorDropPrimary() |
default <R> Ior<ST,R> |
trampoline(java.util.function.Function<? super PT,? extends Trampoline<? extends R>> mapper)
Performs a map operation that can call a recursive method without running out of stack space
|
default <T> Ior<ST,T> |
unit(T unit) |
default <R> R |
visit(java.util.function.Function<? super ST,? extends R> secondary,
java.util.function.Function<? super PT,? extends R> primary,
java.util.function.BiFunction<? super ST,? super PT,? extends R> both) |
default <R1,R2> Ior<R1,R2> |
visitIor(java.util.function.Function<? super ST,? extends R1> secondary,
java.util.function.Function<? super PT,? extends R2> primary) |
isPresentap, ap, ap1, ap2, ap3, ap4, ap5fold, fold, generate, iterate, mapReduce, mkString, newSubscriber, of, stream, subscribe, test, toDequeX, toEvalAlways, toEvalLater, toEvalNow, toFeatureToggle, toFutureStream, toFutureStream, toLazyImmutable, toListX, toMaybe, toMutable, toPBagX, toPOrderedSetX, toPQueueX, toPSetX, toPStackX, toPVectorX, toQueueX, toSetX, toSimpleReact, toSimpleReact, toSortedSetX, toTry, toTry, toTry, unapply, visitendsWith, endsWithIterable, findAny, findFirst, firstValue, foldable, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, headAndTail, 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, visit, visit, xMatchfromSupplier, iterator, orElse, orElseGet, orElseThrow, toAtomicReference, toCompletableFuture, toCompletableFutureAsync, toCompletableFutureAsync, toFutureW, toList, toOptional, toOptionalAtomicReference, toStreamstatic <ST,PT> Ior<ST,PT> primary(PT primary)
static <ST,PT> Ior<ST,PT> secondary(ST secondary)
static <ST,PT> Ior<ST,PT> both(ST secondary, PT primary)
default AnyMValue<PT> anyM()
anyM in interface MonadicValue<PT>default <T> Ior<ST,T> unit(T unit)
unit in interface MonadicValue<PT>unit in interface MonadicValue2<ST,PT>unit in interface Unit<PT>Ior<ST,PT> filter(java.util.function.Predicate<? super PT> test)
Filterable
of(1,2,3).filter(i->i>2);
//[3]
filter in interface Filterable<PT>test - to filter elements by, retaining matchesdefault <ST2> Xor<ST2,PT> toXor(ST2 secondary)
ValueIor<ST,PT> secondaryToPrimayMap(java.util.function.Function<? super ST,? extends PT> fn)
<R> Ior<ST,R> map(java.util.function.Function<? super PT,? extends R> fn)
Functor
of(1,2,3).map(i->i*2)
//[2,4,6]
map in interface ConvertableFunctor<PT>map in interface Functor<PT>map in interface MonadicValue<PT>map in interface MonadicValue2<ST,PT>fn - Transformation functionIor<ST,PT> peek(java.util.function.Consumer<? super PT> action)
Functor
of(1,2,3).map(System.out::println)
1
2
3
default <R> Ior<ST,R> coflatMap(java.util.function.Function<? super MonadicValue<PT>,R> mapper)
coflatMap in interface MonadicValue<PT>default Ior<ST,MonadicValue<PT>> nest()
nest in interface MonadicValue<PT>default Ior<ST,PT> combine(Monoid<PT> monoid, MonadicValue2<? extends ST,? extends PT> v2)
MonadicValue2
Monoid<Integer> add = Mondoid.of(1,Semigroups.intSum);
Maybe.of(10).plus(add,Maybe.none());
//Maybe[10]
Maybe.none().plus(add,Maybe.of(10));
//Maybe[10]
Maybe.none().plus(add,Maybe.none());
//Maybe.none()
Maybe.of(10).plus(add,Maybe.of(10));
//Maybe[20]
Monoid<Integer> firstNonNull = Monoid.of(null , Semigroups.firstNonNull());
Maybe.of(10).plus(firstNonNull,Maybe.of(10));
//Maybe[10]
combine in interface MonadicValue2<ST,PT>default <R> Xor<ST,R> patternMatch(java.util.function.Function<Matchable.CheckValue1<PT,R>,Matchable.CheckValue1<PT,R>> case1, java.util.function.Supplier<? extends R> otherwise)
Functor
List<String> result = CollectionX.of(1,2,3,4)
.patternMatch(
c->c.valuesWhere(i->"even", (Integer i)->i%2==0 )
)
// CollectionX["odd","even","odd","even"]
patternMatch in interface Functor<PT>case1 - Function to generate a case (or chain of cases as a single case)otherwise - Value if supplied case doesn't matchdefault <R1,R2> Ior<R1,R2> bimap(java.util.function.Function<? super ST,? extends R1> fn1, java.util.function.Function<? super PT,? extends R2> fn2)
default <R> R visit(java.util.function.Function<? super ST,? extends R> secondary, java.util.function.Function<? super PT,? extends R> primary, java.util.function.BiFunction<? super ST,? super PT,? extends R> both)
default <R1,R2> Ior<R1,R2> visitIor(java.util.function.Function<? super ST,? extends R1> secondary, java.util.function.Function<? super PT,? extends R2> primary)
<R> Eval<R> matches(java.util.function.Function<Matchable.CheckValue1<ST,R>,Matchable.CheckValue1<ST,R>> secondary, java.util.function.Function<Matchable.CheckValue1<PT,R>,Matchable.CheckValue1<PT,R>> primary, java.util.function.Function<Matchable.CheckValue2<ST,PT,R>,Matchable.CheckValue2<ST,PT,R>> both, java.util.function.Supplier<? extends R> otherwise)
PT get()
get in interface Convertable<PT>get in interface java.util.function.Supplier<PT>ST secondaryGet()
java.util.Optional<ST> secondaryToOptional()
ReactiveSeq<ST> secondaryToStream()
<LT1,RT1> Ior<LT1,RT1> flatMap(java.util.function.Function<? super PT,? extends MonadicValue2<? extends LT1,? extends RT1>> mapper)
flatMap in interface MonadicValue2<ST,PT><LT1,RT1> Ior<LT1,RT1> secondaryFlatMap(java.util.function.Function<? super ST,? extends Ior<LT1,RT1>> mapper)
Ior<ST,PT> secondaryToPrimayFlatMap(java.util.function.Function<? super ST,? extends Ior<ST,PT>> fn)
boolean isPrimary()
boolean isSecondary()
boolean isBoth()
static <ST,PT> Ior<ListX<PT>,ListX<ST>> sequenceSecondary(CollectionX<Ior<ST,PT>> iors)
static <ST,PT,R> Ior<?,R> accumulateSecondary(CollectionX<Ior<ST,PT>> iors, Reducer<R> reducer)
static <ST,PT,R> Ior<?,R> accumulateSecondary(CollectionX<Ior<ST,PT>> iors, java.util.function.Function<? super ST,R> mapper, Semigroup<R> reducer)
static <ST,PT> Ior<?,ST> accumulateSecondary(CollectionX<Ior<ST,PT>> iors, Semigroup<ST> reducer)
static <ST,PT> Ior<ListX<ST>,ListX<PT>> sequencePrimary(CollectionX<Ior<ST,PT>> iors)
static <ST,PT,R> Ior<?,R> accumulatePrimary(CollectionX<Ior<ST,PT>> iors, Reducer<R> reducer)
static <ST,PT,R> Ior<?,R> accumulatePrimary(CollectionX<Ior<ST,PT>> iors, java.util.function.Function<? super PT,R> mapper, Semigroup<R> reducer)
static <ST,PT> Ior<?,PT> accumulatePrimary(CollectionX<Ior<ST,PT>> iors, Semigroup<PT> reducer)
default <U> Ior<ST,U> ofType(java.lang.Class<? extends U> type)
Filterable
// (1, 2, 3) ReactiveSeq.of(1, "a", 2, "b",3).ofType(Integer.class)
ofType in interface Filterable<PT>default Ior<ST,PT> filterNot(java.util.function.Predicate<? super PT> fn)
Filterable
of(1,2,3).filter(i->i>2);
//[1,2]
filterNot in interface Filterable<PT>fn - to filter elements by, retaining matchesdefault Ior<ST,PT> notNull()
Filterable
of(1,2,null,4).nonNull();
//[1,2,4]
notNull in interface Filterable<PT>default <U> Ior<ST,U> cast(java.lang.Class<? extends U> type)
FunctorClassCastException.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)default <R> Ior<ST,R> trampoline(java.util.function.Function<? super PT,? extends Trampoline<? extends R>> mapper)
Functor
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 Functor<PT>default Ior<ST,PT> bipeek(java.util.function.Consumer<? super ST> c1, java.util.function.Consumer<? super PT> c2)
default <U1,U2> Ior<U1,U2> bicast(java.lang.Class<U1> type1, java.lang.Class<U2> type2)
BiFunctorClassCastException.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)default <R1,R2> Ior<R1,R2> bitrampoline(java.util.function.Function<? super ST,? extends Trampoline<? extends R1>> mapper1, java.util.function.Function<? super PT,? extends Trampoline<? extends R2>> mapper2)
BiFunctor
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
bitrampoline in interface BiFunctor<ST,PT>