public class Product<W1,W2,T> extends java.lang.Object implements Filters<T>, Higher3<Witness.product,W1,W2,T>, Transformable<T>, To<Product<W1,W2,T>>
| Modifier and Type | Class and Description |
|---|---|
static class |
Product.Instances<W1,W2> |
class |
Product.Plus |
class |
Product.Unfolds |
| Constructor and Description |
|---|
Product() |
| Modifier and Type | Method and Description |
|---|---|
Active<W1,T> |
activeFirst(SemigroupK<W1,T> sg,
Higher<W1,T> concat) |
Active<W2,T> |
activeSecond(SemigroupK<W2,T> sg,
Higher<W2,T> concat) |
Active<Higher<Higher<Witness.product,W1>,W2>,T> |
allTypeClasses() |
org.jooq.lambda.tuple.Tuple2<Active<W1,T>,Active<W2,T>> |
asActiveTuple() |
org.jooq.lambda.tuple.Tuple2<Higher<W1,T>,Higher<W2,T>> |
asTuple() |
<U> Product<W1,W2,U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a reactiveStream to a given type, possibly throwing a
ClassCastException. |
Coproduct<W1,W2,T> |
coproduct(java.util.function.BiPredicate<Higher<W1,T>,Higher<W2,T>> test) |
Product<W1,W2,T> |
filter(java.util.function.Predicate<? super T> test)
Keep only elements for which the supplied predicates hold
e.g.
|
Product<W1,W2,T> |
filterNot(java.util.function.Predicate<? super T> predicate)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
<R> Product<W1,W2,R> |
flatMap(java.util.function.Function<? super T,? extends Product<W1,W2,R>> fn) |
<C2,T> Higher<C2,Product<W1,W2,T>> |
flatSequenceA(Applicative<C2> applicative,
Product<W1,W2,Higher<C2,Product<W1,W2,T>>> fgfa) |
<C2,R> Higher<C2,Product<W1,W2,R>> |
flatTraverseA(Applicative<C2> applicative,
java.util.function.Function<? super T,? extends Higher<C2,Product<W1,W2,R>>> f) |
T |
foldLeft(Monoid<T> monoid) |
T |
foldLeft(T identity,
java.util.function.BinaryOperator<T> semigroup) |
org.jooq.lambda.tuple.Tuple2<T,T> |
foldLeftTuple(Monoid<T> monoid) |
org.jooq.lambda.tuple.Tuple2<T,T> |
foldLeftTuple(T identity,
java.util.function.BinaryOperator<T> semigroup) |
<R> R |
foldMap(Monoid<R> mb,
java.util.function.Function<? super T,? extends R> fn) |
<R> org.jooq.lambda.tuple.Tuple2<R,R> |
foldMapTuple(Monoid<R> mb,
java.util.function.Function<? super T,? extends R> fn) |
T |
foldRight(Monoid<T> monoid) |
T |
foldRight(T identity,
java.util.function.BinaryOperator<T> semigroup) |
org.jooq.lambda.tuple.Tuple2<T,T> |
foldRightTuple(Monoid<T> monoid) |
org.jooq.lambda.tuple.Tuple2<T,T> |
foldRightTuple(T identity,
java.util.function.BinaryOperator<T> semigroup) |
<R1,R> Product<W1,W2,R> |
forEach2(java.util.function.Function<? super T,? extends Product<W1,W2,R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction) |
<T2,R1,R2,R> |
forEach3(java.util.function.Function<? super T,? extends Product<W1,W2,R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends Product<W1,W2,R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction) |
<T2,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super T,? extends Product<W1,W2,R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends Product<W1,W2,R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends Product<W1,W2,R3>> value3,
Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
<R> Product<W1,W2,R> |
map(java.util.function.Function<? super T,? extends R> fn)
Transform this functor using the supplied transformation function
|
<R> Product<W1,W2,R> |
mapWithIndex(java.util.function.BiFunction<? super T,java.lang.Long,? extends R> f) |
static <W1,W2,T> Product<W1,W2,T> |
narrowK(Higher<Higher<Higher<Witness.product,W1>,W2>,T> ds) |
Product<W1,W2,T> |
notNull()
Filter elements retaining only values which are not null
|
static <W1,W2,T> Product<W1,W2,T> |
of(Active<W1,T> a1,
Active<W2,T> a2) |
static <W1,W2,T> Product<W1,W2,T> |
of(org.jooq.lambda.tuple.Tuple2<Higher<W1,T>,Higher<W2,T>> run,
InstanceDefinitions<W1> def1,
InstanceDefinitions<W2> def2) |
<U> Product<W1,W2,U> |
ofType(java.lang.Class<? extends U> type)
Keep only those elements in a reactiveStream that are of a given type.
|
Product<W1,W2,T> |
peek(java.util.function.Consumer<? super T> c)
Peek at the current value of this Transformable, without transforming it
|
Maybe<Product.Plus> |
plus() |
Product<W1,W2,T> |
plusFirst(SemigroupK<W1,T> semigroupK,
Higher<W1,T> add) |
Product<W1,W2,T> |
plusSecond(SemigroupK<W2,T> semigroupK,
Higher<W2,T> add) |
Product.Plus |
plusUnsafe() |
<R> Product<W1,W2,R> |
retry(java.util.function.Function<? super T,? extends R> fn)
Retry a transformation if it fails.
|
<R> Product<W1,W2,R> |
retry(java.util.function.Function<? super T,? extends R> fn,
int retries,
long delay,
java.util.concurrent.TimeUnit timeUnit)
Retry a transformation if it fails.
|
Product<W1,W2,T> |
reverse() |
<C2,T> Higher<C2,Product<W1,W2,T>> |
sequenceA(Applicative<C2> applicative,
Product<W1,W2,Higher<C2,T>> ds) |
org.jooq.lambda.tuple.Tuple2<java.lang.Long,java.lang.Long> |
size() |
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
stream() |
ReactiveSeq<T> |
streamBoth() |
Product<W2,W1,T> |
swap() |
<R> Active<W1,R> |
tailRec1(T initial,
java.util.function.Function<? super T,? extends Higher<W1,? extends Xor<T,R>>> fn) |
<R> Active<W2,R> |
tailRec2(T initial,
java.util.function.Function<? super T,? extends Higher<W2,? extends Xor<T,R>>> fn) |
org.jooq.lambda.tuple.Tuple2<ListX<T>,ListX<T>> |
toListX() |
ListX<T> |
toListXBoth() |
java.lang.String |
toString() |
long |
totalSize() |
<R> Product<W1,W2,R> |
trampoline(java.util.function.Function<? super T,? extends Trampoline<? extends R>> mapper)
Performs a map operation that can call a recursive method without running out of stack space
|
<C2,R> Higher<C2,Product<W1,W2,R>> |
traverseA(Applicative<C2> applicative,
java.util.function.Function<? super T,? extends Higher<C2,R>> fn) |
static <W1,W2,T,C2,R> |
traverseA(Applicative<C2> applicative,
java.util.function.Function<? super T,? extends Higher<C2,R>> fn,
Product<W1,W2,T> n) |
Maybe<Product.Unfolds> |
unfolds() |
Product.Unfolds |
unfoldsDefault() |
Active<W1,T> |
v1() |
Active<W2,T> |
v2() |
<R> R |
visit(java.util.function.BiFunction<? super Higher<W1,? super T>,? super Higher<W2,? super T>,? extends R> visitor) |
<R> R |
visitA(java.util.function.BiFunction<? super Active<W1,? super T>,? super Active<W2,? super T>,? extends R> visitor) |
Product<W1,W2,org.jooq.lambda.tuple.Tuple2<T,T>> |
zip(Product<W1,W2,T> p2) |
<R> Product<W1,W2,R> |
zip(Product<W1,W2,T> p2,
java.util.function.BiFunction<? super T,? super T,? extends R> zipper) |
Product<W1,W2,org.jooq.lambda.tuple.Tuple3<T,T,T>> |
zip(Product<W1,W2,T> p2,
Product<W1,W2,T> p3) |
<R> Product<W1,W2,R> |
zip(Product<W1,W2,T> p2,
Product<W1,W2,T> p3,
Fn3<? super T,? super T,? super T,? extends R> zipper) |
<R> Product<W1,W2,org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> |
zipWithIndex() |
<W2,T2,R> Active<W1,R> |
zipWithSecond(java.util.function.BiFunction<? super T,? super Maybe<T>,? extends R> f) |
public static <W1,W2,T> Product<W1,W2,T> of(org.jooq.lambda.tuple.Tuple2<Higher<W1,T>,Higher<W2,T>> run, InstanceDefinitions<W1> def1, InstanceDefinitions<W2> def2)
public Coproduct<W1,W2,T> coproduct(java.util.function.BiPredicate<Higher<W1,T>,Higher<W2,T>> test)
public Product<W1,W2,T> filter(java.util.function.Predicate<? super T> test)
Filters
of(1,2,3).filter(i->i>2);
//[3]
public <U> Product<W1,W2,U> ofType(java.lang.Class<? extends U> type)
Filters
// (1, 2, 3) ReactiveSeq.of(1, "a", 2, "b",3).ofType(Integer.class)
public Product<W1,W2,T> filterNot(java.util.function.Predicate<? super T> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
public Product<W1,W2,T> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
public <U> Product<W1,W2,U> cast(java.lang.Class<? extends U> type)
TransformableClassCastException.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)cast in interface Transformable<T>public <W2,T2,R> Active<W1,R> zipWithSecond(java.util.function.BiFunction<? super T,? super Maybe<T>,? extends R> f)
public Product<W1,W2,org.jooq.lambda.tuple.Tuple3<T,T,T>> zip(Product<W1,W2,T> p2, Product<W1,W2,T> p3)
public <R> Product<W1,W2,R> zip(Product<W1,W2,T> p2, java.util.function.BiFunction<? super T,? super T,? extends R> zipper)
public <R> Product<W1,W2,R> zip(Product<W1,W2,T> p2, Product<W1,W2,T> p3, Fn3<? super T,? super T,? super T,? extends R> zipper)
public <R> Product<W1,W2,R> mapWithIndex(java.util.function.BiFunction<? super T,java.lang.Long,? extends R> f)
public <R> Product<W1,W2,org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> zipWithIndex()
public <R> Product<W1,W2,R> map(java.util.function.Function<? super T,? extends R> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
map in interface Transformable<T>fn - Transformation functionpublic <R> Product<W1,W2,R> flatMap(java.util.function.Function<? super T,? extends Product<W1,W2,R>> fn)
public Product<W1,W2,T> peek(java.util.function.Consumer<? super T> c)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
peek in interface Transformable<T>c - Consumer that recieves each element from this Transformablepublic java.lang.String toString()
toString in class java.lang.Objectpublic <R> Product<W1,W2,R> trampoline(java.util.function.Function<? super T,? 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<T>mapper - TCO Transformation functionpublic <R> Product<W1,W2,R> retry(java.util.function.Function<? super T,? 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<T>fn - Function to retry if failspublic <R> Product<W1,W2,R> retry(java.util.function.Function<? super T,? 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<T>fn - Function to retry if failsretries - Number of retriesdelay - Delay in TimeUnitstimeUnit - TimeUnit to use for delaypublic <R> Active<W1,R> tailRec1(T initial, java.util.function.Function<? super T,? extends Higher<W1,? extends Xor<T,R>>> fn)
public <R> Active<W2,R> tailRec2(T initial, java.util.function.Function<? super T,? extends Higher<W2,? extends Xor<T,R>>> fn)
public <R> R visit(java.util.function.BiFunction<? super Higher<W1,? super T>,? super Higher<W2,? super T>,? extends R> visitor)
public <R> R visitA(java.util.function.BiFunction<? super Active<W1,? super T>,? super Active<W2,? super T>,? extends R> visitor)
public Product.Unfolds unfoldsDefault()
public Maybe<Product.Unfolds> unfolds()
public Product.Plus plusUnsafe()
public Maybe<Product.Plus> plus()
public org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> stream()
public ReactiveSeq<T> streamBoth()
public org.jooq.lambda.tuple.Tuple2<java.lang.Long,java.lang.Long> size()
public long totalSize()
public <R> org.jooq.lambda.tuple.Tuple2<R,R> foldMapTuple(Monoid<R> mb, java.util.function.Function<? super T,? extends R> fn)
public org.jooq.lambda.tuple.Tuple2<T,T> foldRightTuple(T identity, java.util.function.BinaryOperator<T> semigroup)
public org.jooq.lambda.tuple.Tuple2<T,T> foldLeftTuple(T identity, java.util.function.BinaryOperator<T> semigroup)
public <R1,R> Product<W1,W2,R> forEach2(java.util.function.Function<? super T,? extends Product<W1,W2,R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
public <T2,R1,R2,R> Product<W1,W2,R> forEach3(java.util.function.Function<? super T,? extends Product<W1,W2,R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends Product<W1,W2,R2>> value2, Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
public <T2,R1,R2,R3,R> Product<W1,W2,R> forEach4(java.util.function.Function<? super T,? extends Product<W1,W2,R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends Product<W1,W2,R2>> value2, Fn3<? super T,? super R1,? super R2,? extends Product<W1,W2,R3>> value3, Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
public static <W1,W2,T> Product<W1,W2,T> narrowK(Higher<Higher<Higher<Witness.product,W1>,W2>,T> ds)
public <C2,R> Higher<C2,Product<W1,W2,R>> traverseA(Applicative<C2> applicative, java.util.function.Function<? super T,? extends Higher<C2,R>> fn)
public static <W1,W2,T,C2,R> Higher<C2,Product<W1,W2,R>> traverseA(Applicative<C2> applicative, java.util.function.Function<? super T,? extends Higher<C2,R>> fn, Product<W1,W2,T> n)
public <C2,T> Higher<C2,Product<W1,W2,T>> sequenceA(Applicative<C2> applicative, Product<W1,W2,Higher<C2,T>> ds)
public <C2,R> Higher<C2,Product<W1,W2,R>> flatTraverseA(Applicative<C2> applicative, java.util.function.Function<? super T,? extends Higher<C2,Product<W1,W2,R>>> f)