T
- Type of data stored inside the nested Future(s)public final class FutureT<W extends WitnessType<W>,T> extends ValueTransformer<W,T> implements To<FutureT<W,T>>, Transformable<T>, Filters<T>
Fn0.FunctionalOperations<R>, Fn0.Instances, Fn0.SupplierKind<R>
Modifier and Type | Method and Description |
---|---|
<U> FutureT<W,U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a stream to a given type, possibly throwing a
ClassCastException . |
<T2,R> FutureT<W,R> |
combine(Value<? extends T2> app,
java.util.function.BiFunction<? super T,? super T2,? extends R> fn) |
<R> FutureT<W,R> |
empty() |
boolean |
equals(java.lang.Object o) |
FutureT<W,T> |
filter(java.util.function.Predicate<? super T> test)
Keep only elements for which the supplied predicates hold
e.g.
|
FutureT<W,T> |
filterNot(java.util.function.Predicate<? super T> predicate)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
<B> FutureT<W,B> |
flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends B>> f) |
<R> FutureT<W,R> |
flatMapIterable(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> mapper) |
<R> FutureT<W,R> |
flatMapPublisher(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper) |
<B> FutureT<W,B> |
flatMapT(java.util.function.Function<? super T,FutureT<W,B>> f)
Flat Map the wrapped Future
|
<R1,R> FutureT<W,R> |
forEach2(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction) |
<R1,R> FutureT<W,R> |
forEach2(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,java.lang.Boolean> filterFunction,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction) |
<R1,R> FutureT<W,R> |
forEach2M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction) |
<R1,R> FutureT<W,R> |
forEach2M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1,
java.util.function.BiFunction<? super T,? super R1,java.lang.Boolean> filterFunction,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction) |
<T2,R1,R2,R> |
forEach3(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction) |
<T2,R1,R2,R> |
forEach3(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super T,? super R1,? super R2,java.lang.Boolean> filterFunction,
Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction) |
<T2,R1,R2,R> |
forEach3M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends FutureT<W,R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction) |
<T2,R1,R2,R> |
forEach3M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends FutureT<W,R2>> value2,
Fn3<? super T,? super R1,? super R2,java.lang.Boolean> filterFunction,
Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction) |
<T2,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends MonadicValue<R3>> value3,
Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
<T2,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends MonadicValue<R3>> value3,
Fn4<? super T,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction,
Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
<T2,R1,R2,R3,R> |
forEach4M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends FutureT<W,R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends FutureT<W,R3>> value3,
Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
<T2,R1,R2,R3,R> |
forEach4M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends FutureT<W,R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends FutureT<W,R3>> value3,
Fn4<? super T,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction,
Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
static <W extends WitnessType<W>,A> |
fromAnyM(AnyM<W,A> anyM)
|
AnyM<W,? extends ReactiveSeq<T>> |
generate() |
int |
hashCode() |
AnyM<W,? extends ReactiveSeq<T>> |
iterate(java.util.function.UnaryOperator<T> fn)
public AnyM
|
java.util.Iterator<T> |
iterator() |
static <W extends WitnessType<W>,U,R> |
lift(java.util.function.Function<? super U,? extends R> fn)
Lift a function into one that accepts and returns an FutureWT
This allows multiple monad types to add functionality to existing function and methods
e.g.
|
static <W extends WitnessType<W>,U1,U2,R> |
lift2(java.util.function.BiFunction<? super U1,? super U2,? extends R> fn)
Lift a BiFunction into one that accepts and returns FutureWTs
This allows multiple monad types to add functionality to existing function and methods
e.g.
|
<B> FutureT<W,B> |
map(java.util.function.Function<? super T,? extends B> f)
Map the wrapped Future
|
<B> FutureT<W,B> |
map(java.util.function.Function<? super T,? extends B> f,
java.util.concurrent.Executor ex) |
java.lang.String |
mkString() |
FutureT<W,T> |
notNull()
Filter elements retaining only values which are not null
|
static <W extends WitnessType<W>,A> |
of(AnyM<W,Future<A>> monads)
Construct an FutureWT from an AnyM that wraps a monad containing FutureWs
|
<U> FutureT<W,U> |
ofType(java.lang.Class<? extends U> type)
Keep only those elements in a stream that are of a given type.
|
FutureT<W,T> |
peek(java.util.function.Consumer<? super T> peek)
Peek at the current value of the Future
|
ReactiveSeq<T> |
stream() |
java.lang.String |
toString() |
<R> FutureT<W,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
|
AnyM<W,? extends MonadicValue<T>> |
transformerStream() |
<R> FutureT<W,R> |
unit(R value) |
protected <R> FutureT<W,R> |
unitAnyM(AnyM<W,? super MonadicValue<R>> traversable)
Deprecated.
|
<R> FutureT<W,R> |
unitIterator(java.util.Iterator<R> it) |
AnyM<W,Future<T>> |
unwrap()
Unwrap a wrapped value
|
FutureT<W,T> |
zip(java.util.function.BinaryOperator<Zippable<T>> combiner,
Zippable<T> app)
Combine two applicatives together using the provided BinaryOperator (Semigroup, Monoid and Reducer all
extend BinaryOperator - checkout Semigroups and Monoids for a large number of canned combinations).
|
<T2,R> FutureT<W,R> |
zip(java.lang.Iterable<? extends T2> iterable,
java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zip (combine) this Zippable with the supplied Iterable using the supplied combining function
|
<U> FutureT<W,org.jooq.lambda.tuple.Tuple2<T,U>> |
zip(java.lang.Iterable<? extends U> other)
Zip (combine) this Zippable with the supplied Iterable combining both into a Tuple2
|
<S,U> FutureT<W,org.jooq.lambda.tuple.Tuple3<T,S,U>> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third)
zip 3 Streams into one
|
<S,U,R> FutureT<W,R> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third,
Fn3<? super T,? super S,? super U,? extends R> fn3) |
<T2,T3,T4> FutureT<W,org.jooq.lambda.tuple.Tuple4<T,T2,T3,T4>> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth)
zip 4 Streams into 1
|
<T2,T3,T4,R> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth,
Fn4<? super T,? super T2,? super T3,? super T4,? extends R> fn) |
<T2,R> FutureT<W,R> |
zipP(org.reactivestreams.Publisher<? extends T2> publisher,
java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zip (combine) this Zippable with the supplied Publisher, using the supplied combining function
|
<U> FutureT<W,org.jooq.lambda.tuple.Tuple2<T,U>> |
zipP(org.reactivestreams.Publisher<? extends U> other) |
<U> FutureT<W,org.jooq.lambda.tuple.Tuple2<T,U>> |
zipS(java.util.stream.Stream<? extends U> other)
Zip (combine) this Zippable with the supplied Stream combining both into a Tuple2
|
<U,R> FutureT<W,R> |
zipS(java.util.stream.Stream<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Stream, using the supplied combining function
|
<R> FutureT<W,R> |
zipWith(java.lang.Iterable<java.util.function.Function<? super T,? extends R>> fn) |
<R> FutureT<W,R> |
zipWithP(org.reactivestreams.Publisher<java.util.function.Function<? super T,? extends R>> fn) |
<R> FutureT<W,R> |
zipWithS(java.util.stream.Stream<java.util.function.Function<? super T,? extends R>> fn) |
and, get, isPresent, negate, or, orElse, orElseGet, orElseThrow, subscribe, visit, zip
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
retry, retry
endsWith, endsWithIterable, findAny, findFirst, firstValue, foldLeft, foldLeft, foldLeft, foldLeft, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, join, join, join, mapReduce, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce, schedule, scheduleFixedDelay, scheduleFixedRate, single, single, singleOptional, startsWith, startsWithIterable, toConcurrentLazyCollection, toConcurrentLazyStreamable, toLazyCollection, xMatch
futureStream, getStreamable, isEmpty, jdkStream, reactiveSeq, reveresedJDKStream, reveresedStream
public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
public ReactiveSeq<T> stream()
public AnyM<W,Future<T>> unwrap()
Unwrapable
unwrap
in interface Unwrapable
@Deprecated protected <R> FutureT<W,R> unitAnyM(AnyM<W,? super MonadicValue<R>> traversable)
unitAnyM
in class ValueTransformer<W extends WitnessType<W>,T>
public AnyM<W,? extends MonadicValue<T>> transformerStream()
transformerStream
in class ValueTransformer<W extends WitnessType<W>,T>
public FutureT<W,T> filter(java.util.function.Predicate<? super T> test)
Filters
of(1,2,3).filter(i->i>2);
//[3]
public FutureT<W,T> peek(java.util.function.Consumer<? super T> peek)
FutureWT.of(AnyM.fromStream(Arrays.asFutureW(10))
.peek(System.out::println);
//prints 10
peek
in interface Transformable<T>
peek
- Consumer to accept current value of Futurepublic <B> FutureT<W,B> map(java.util.function.Function<? super T,? extends B> f)
FutureWT.of(AnyM.fromStream(Arrays.asFutureW(10))
.map(t->t=t+1);
//FutureWT<AnyMSeq<Stream<Future[11]>>>
map
in interface Transformable<T>
f
- Mapping function for the wrapped Futurepublic <B> FutureT<W,B> map(java.util.function.Function<? super T,? extends B> f, java.util.concurrent.Executor ex)
public <B> FutureT<W,B> flatMapT(java.util.function.Function<? super T,FutureT<W,B>> f)
FutureWT.of(AnyM.fromStream(Arrays.asFutureW(10))
.flatMap(t->Future.completedFuture(20));
//FutureWT<AnyMSeq<Stream<Future[20]>>>
f
- FlatMap functionpublic <B> FutureT<W,B> flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends B>> f)
flatMap
in class ValueTransformer<W extends WitnessType<W>,T>
public static <W extends WitnessType<W>,U,R> java.util.function.Function<FutureT<W,U>,FutureT<W,R>> lift(java.util.function.Function<? super U,? extends R> fn)
Function<Integer,Integer> add2 = i -> i+2;
Function<FutureWT<Integer>, FutureWT<Integer>> optTAdd2 = FutureWT.lift(add2);
Stream<Integer> withNulls = Stream.of(1,2,3);
AnyMSeq<Integer> stream = AnyM.fromStream(withNulls);
AnyMSeq<Future<Integer>> streamOpt = stream.map(Future::completedFuture);
List<Integer> results = optTAdd2.apply(FutureWT.of(streamOpt))
.unwrap()
.<Stream<Future<Integer>>>unwrap()
.map(Future::join)
.collect(Collectors.toList());
//Future.completedFuture(List[3,4]);
fn
- Function to enhance with functionality from Future and another monad typepublic static <W extends WitnessType<W>,U1,U2,R> java.util.function.BiFunction<FutureT<W,U1>,FutureT<W,U2>,FutureT<W,R>> lift2(java.util.function.BiFunction<? super U1,? super U2,? extends R> fn)
BiFunction<Integer,Integer,Integer> add = (a,b) -> a+b;
BiFunction<FutureWT<Integer>,FutureWT<Integer>,FutureWT<Integer>> optTAdd2 = FutureWT.lift2(add);
Stream<Integer> withNulls = Stream.of(1,2,3);
AnyMSeq<Integer> stream = AnyM.ofMonad(withNulls);
AnyMSeq<Future<Integer>> streamOpt = stream.map(Future::completedFuture);
Future<Future<Integer>> two = Future.completedFuture(Future.completedFuture(2));
AnyMSeq<Future<Integer>> future= AnyM.fromFutureW(two);
List<Integer> results = optTAdd2.apply(FutureWT.of(streamOpt),FutureWT.of(future))
.unwrap()
.<Stream<Future<Integer>>>unwrap()
.map(Future::join)
.collect(Collectors.toList());
//Future.completedFuture(List[3,4,5]);
fn
- BiFunction to enhance with functionality from Future and another monad typepublic static <W extends WitnessType<W>,A> FutureT<W,A> fromAnyM(AnyM<W,A> anyM)
anyM
- AnyM that doesn't contain a monad wrapping an Futurepublic static <W extends WitnessType<W>,A> FutureT<W,A> of(AnyM<W,Future<A>> monads)
monads
- AnyM that contains a monad wrapping an Futurepublic java.lang.String toString()
toString
in class java.lang.Object
public <R> FutureT<W,R> empty()
empty
in class ValueTransformer<W extends WitnessType<W>,T>
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public <T2,R> FutureT<W,R> combine(Value<? extends T2> app, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
combine
in class ValueTransformer<W extends WitnessType<W>,T>
public FutureT<W,T> zip(java.util.function.BinaryOperator<Zippable<T>> combiner, Zippable<T> app)
Zippable
zip
in interface Zippable<T>
zip
in class ValueTransformer<W extends WitnessType<W>,T>
Semigroup
,
Semigroups
,
Monoid
,
To lift any Semigroup (or monoid) up to handling Applicatives use the combineApplicatives operator in Semigroups
{@see com.aol.cyclops2.Semigroups#combineApplicatives(BiFunction) } or Monoids
{ {@see com.aol.cyclops2.Monoids#combineApplicatives(java.util.function.Function, com.aol.cyclops2.function.Monoid)
}
{@code
BinaryOperator> sumMaybes = Semigroups.combineScalarFunctors(Semigroups.intSum);
Maybe.just(1).zip(sumMaybes, Maybe.just(5))
//Maybe.just(6));
}
public AnyM<W,? extends ReactiveSeq<T>> iterate(java.util.function.UnaryOperator<T> fn)
ValueTransformer
iterate
in class ValueTransformer<W extends WitnessType<W>,T>
public AnyM<W,? extends ReactiveSeq<T>> generate()
generate
in class ValueTransformer<W extends WitnessType<W>,T>
public <T2,R> FutureT<W,R> zip(java.lang.Iterable<? extends T2> iterable, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zippable
zip
in interface Zippable<T>
zip
in class ValueTransformer<W extends WitnessType<W>,T>
iterable
- to zip withfn
- Zip functionpublic <T2,R> FutureT<W,R> zipP(org.reactivestreams.Publisher<? extends T2> publisher, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zippable
zipP
in interface Zippable<T>
zipP
in class ValueTransformer<W extends WitnessType<W>,T>
publisher
- to combine withfn
- Zip / combining functionpublic <U> FutureT<W,org.jooq.lambda.tuple.Tuple2<T,U>> zipS(java.util.stream.Stream<? extends U> other)
Zippable
zipS
in interface Zippable<T>
zipS
in class ValueTransformer<W extends WitnessType<W>,T>
other
- Stream to combine withpublic <U> FutureT<W,org.jooq.lambda.tuple.Tuple2<T,U>> zip(java.lang.Iterable<? extends U> other)
Zippable
zip
in interface Zippable<T>
zip
in class ValueTransformer<W extends WitnessType<W>,T>
other
- Iterable to combine withpublic <T2,R1,R2,R3,R> FutureT<W,R> forEach4(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super T,? super R1,? super R2,? extends MonadicValue<R3>> value3, Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
forEach4
in class ValueTransformer<W extends WitnessType<W>,T>
public <T2,R1,R2,R3,R> FutureT<W,R> forEach4(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super T,? super R1,? super R2,? extends MonadicValue<R3>> value3, Fn4<? super T,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction, Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
forEach4
in class ValueTransformer<W extends WitnessType<W>,T>
public <T2,R1,R2,R> FutureT<W,R> forEach3(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
forEach3
in class ValueTransformer<W extends WitnessType<W>,T>
public <T2,R1,R2,R> FutureT<W,R> forEach3(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super T,? super R1,? super R2,java.lang.Boolean> filterFunction, Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
forEach3
in class ValueTransformer<W extends WitnessType<W>,T>
public <R1,R> FutureT<W,R> forEach2(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
forEach2
in class ValueTransformer<W extends WitnessType<W>,T>
public <R1,R> FutureT<W,R> forEach2(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,java.lang.Boolean> filterFunction, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
forEach2
in class ValueTransformer<W extends WitnessType<W>,T>
public <R> FutureT<W,R> flatMapIterable(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> mapper)
flatMapIterable
in class ValueTransformer<W extends WitnessType<W>,T>
public <R> FutureT<W,R> flatMapPublisher(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
flatMapPublisher
in class ValueTransformer<W extends WitnessType<W>,T>
public <T2,R1,R2,R3,R> FutureT<W,R> forEach4M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends FutureT<W,R2>> value2, Fn3<? super T,? super R1,? super R2,? extends FutureT<W,R3>> value3, Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
public <T2,R1,R2,R3,R> FutureT<W,R> forEach4M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends FutureT<W,R2>> value2, Fn3<? super T,? super R1,? super R2,? extends FutureT<W,R3>> value3, Fn4<? super T,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction, Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
public <T2,R1,R2,R> FutureT<W,R> forEach3M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends FutureT<W,R2>> value2, Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
public <T2,R1,R2,R> FutureT<W,R> forEach3M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends FutureT<W,R2>> value2, Fn3<? super T,? super R1,? super R2,java.lang.Boolean> filterFunction, Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
public <R1,R> FutureT<W,R> forEach2M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
public <R1,R> FutureT<W,R> forEach2M(java.util.function.Function<? super T,? extends FutureT<W,R1>> value1, java.util.function.BiFunction<? super T,? super R1,java.lang.Boolean> filterFunction, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
public java.lang.String mkString()
public <U> FutureT<W,U> cast(java.lang.Class<? extends U> type)
Transformable
ClassCastException
.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)cast
in interface Transformable<T>
public <U> FutureT<W,U> ofType(java.lang.Class<? extends U> type)
Filters
// (1, 2, 3) ReactiveSeq.of(1, "a", 2, "b",3).ofType(Integer.class)
public FutureT<W,T> filterNot(java.util.function.Predicate<? super T> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
public FutureT<W,T> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
public <R> FutureT<W,R> zipWith(java.lang.Iterable<java.util.function.Function<? super T,? extends R>> fn)
public <R> FutureT<W,R> zipWithS(java.util.stream.Stream<java.util.function.Function<? super T,? extends R>> fn)
public <R> FutureT<W,R> zipWithP(org.reactivestreams.Publisher<java.util.function.Function<? super T,? extends R>> fn)
public <R> FutureT<W,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 <U,R> FutureT<W,R> zipS(java.util.stream.Stream<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zippable
public <U> FutureT<W,org.jooq.lambda.tuple.Tuple2<T,U>> zipP(org.reactivestreams.Publisher<? extends U> other)
public <S,U> FutureT<W,org.jooq.lambda.tuple.Tuple3<T,S,U>> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third)
Zippable
List<Tuple3<Integer, Integer, Character>> list = of(1, 2, 3, 4, 5, 6).zip3(of(100, 200, 300, 400), of('a', 'b', 'c')).collect(Collectors.toList());
// [[1,100,'a'],[2,200,'b'],[3,300,'c']]
public <S,U,R> FutureT<W,R> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third, Fn3<? super T,? super S,? super U,? extends R> fn3)
public <T2,T3,T4> FutureT<W,org.jooq.lambda.tuple.Tuple4<T,T2,T3,T4>> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth)
Zippable
List<Tuple4<Integer, Integer, Character, String>> list = of(1, 2, 3, 4, 5, 6).zip4(of(100, 200, 300, 400), of('a', 'b', 'c'), of("hello", "world"))
.collect(Collectors.toList());
// [[1,100,'a',"hello"],[2,200,'b',"world"]]