public class FutureW<T> extends java.lang.Object implements ConvertableFunctor<T>, Applicativable<T>, MonadicValue<T>, FlatMap<T>, Filterable<T>
Applicativable.Applicatives, Applicativable.SemigroupApplyer<T>
Value.ValueImpl<T>
Matchable.AsMatchable, Matchable.AutoCloseableMatchableIterable<TYPE>, Matchable.CheckValue1<T,R>, Matchable.CheckValue2<T1,T2,R>, Matchable.CheckValue3<T1,T2,T3,R>, Matchable.CheckValue4<T1,T2,T3,T4,R>, Matchable.CheckValue5<T1,T2,T3,T4,T5,R>, Matchable.CheckValueOpt<T,R>, Matchable.CheckValues<T,R>, Matchable.MatchableIterable<TYPE>, Matchable.MatchableObject<TYPE>, Matchable.MatchableOptional<T>, Matchable.MatchSelf<TYPE>, Matchable.MTuple1<T1>, Matchable.MTuple2<T1,T2>, Matchable.MTuple3<T1,T2,T3>, Matchable.MTuple4<T1,T2,T3,T4>, Matchable.MTuple5<T1,T2,T3,T4,T5>, Matchable.MXor<T1,T2>, Matchable.ValueAndOptionalMatcher<T>
Convertable.SupplierToConvertable<T>
Constructor and Description |
---|
FutureW() |
Modifier and Type | Method and Description |
---|---|
static <T,R> FutureW<R> |
accumulate(CollectionX<FutureW<T>> fts,
java.util.function.Function<? super T,R> mapper,
Semigroup<R> reducer) |
static <T,R> FutureW<R> |
accumulate(CollectionX<FutureW<T>> fts,
Reducer<R> reducer) |
static <T> FutureW<T> |
accumulate(CollectionX<FutureW<T>> fts,
Semigroup<T> reducer) |
<U> FutureW<U> |
cast(java.lang.Class<U> type)
Cast all elements in a stream to a given type, possibly throwing a
ClassCastException . |
Maybe<T> |
filter(java.util.function.Predicate<? super T> fn) |
Maybe<T> |
filterNot(java.util.function.Predicate<? super T> fn) |
<R> FutureW<R> |
flatMap(java.util.function.Function<? super T,? extends FutureW<? extends R>> mapper) |
<R> FutureW<R> |
flatMapCf(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<? extends R>> mapper) |
<R> FutureW<R> |
flatten() |
T |
get() |
boolean |
isFailed() |
boolean |
isSuccess() |
java.util.Iterator<T> |
iterator() |
<R> FutureW<R> |
map(java.util.function.Function<? super T,? extends R> fn) |
<R> Eval<R> |
matches(java.util.function.Function<Matchable.CheckValue1<T,R>,Matchable.CheckValue1<T,R>> secondary,
java.util.function.Function<Matchable.CheckValue1<java.lang.Throwable,R>,Matchable.CheckValue1<java.lang.Throwable,R>> primary,
java.util.function.Supplier<? extends R> otherwise) |
java.lang.String |
mkString() |
Maybe<T> |
notNull() |
static <T> FutureW<T> |
of(java.util.concurrent.CompletableFuture<T> f)
Create a new matchable that will match on the fields of the provided Object
|
static <T> FutureW<T> |
ofError(java.lang.Throwable error) |
static <T> FutureW<T> |
ofResult(T result) |
<U> Maybe<U> |
ofType(java.lang.Class<U> type)
Keep only those elements in a stream that are of a given type.
|
<R> FutureW<R> |
patternMatch(java.util.function.Function<Matchable.CheckValues<T,R>,Matchable.CheckValues<T,R>> case1,
java.util.function.Supplier<? extends R> otherwise)
Transform the elements of this Stream with a Pattern Matching case and default value
|
FutureW<T> |
peek(java.util.function.Consumer<? super T> c) |
static <T> FutureW<ListX<T>> |
sequence(CollectionX<FutureW<T>> fts) |
ReactiveSeq<T> |
stream() |
java.util.concurrent.CompletableFuture<T> |
toCompletableFuture() |
java.util.concurrent.CompletableFuture<T> |
toCompletableFutureAsync() |
java.util.concurrent.CompletableFuture<T> |
toCompletableFutureAsync(java.util.concurrent.Executor exec) |
FutureW<T> |
toFutureW() |
Ior<java.lang.Throwable,T> |
toIor() |
java.util.Optional<T> |
toOptional() |
java.lang.String |
toString() |
Xor<java.lang.Throwable,T> |
toXor() |
<R> FutureW<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
|
<T> FutureW<T> |
unit(T unit) |
<R> FutureW<R> |
visit(java.util.function.Function<? super T,R> success,
java.util.function.Function<java.lang.Throwable,R> failure) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
ap, ap, ap1, ap2, ap3, ap4, ap5
convertTo, convertToAsync, fold, fold, generate, getMatchable, iterate, mapReduce, newSubscriber, subscribe, test, toDequeX, toEvalAlways, toEvalLater, toEvalNow, toFutureStream, toFutureStream, toLazyImmutable, toListX, toMaybe, toMutable, toPBagX, toPOrderedSetX, toPQueueX, toPSetX, toPStackX, toPVectorX, toQueueX, toSetX, toSimpleReact, toSimpleReact, toSortedSetX, toTry, toTry, unapply
foldRight, foldRight, foldRight, foldRightMapToType, join, join, join, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce
from, from, from, from, from, from, from, from, from, from, fromCharSequence, fromIterable, fromOptional, listOfValues, ofDecomposable, otherwise, otherwise, then, then, when, when, when, when, when, when, when, when, when, when, whenGuard, whenTrue, whenValues
fromSupplier, orElse, orElseGet, orElseThrow, toAtomicReference, toList, toOptionalAtomicReference, toStream, visit
anyM
public static <T> FutureW<T> of(java.util.concurrent.CompletableFuture<T> f)
Matchable
public static <T> FutureW<ListX<T>> sequence(CollectionX<FutureW<T>> fts)
public static <T,R> FutureW<R> accumulate(CollectionX<FutureW<T>> fts, Reducer<R> reducer)
public static <T,R> FutureW<R> accumulate(CollectionX<FutureW<T>> fts, java.util.function.Function<? super T,R> mapper, Semigroup<R> reducer)
public static <T> FutureW<T> accumulate(CollectionX<FutureW<T>> fts, Semigroup<T> reducer)
public <R> Eval<R> matches(java.util.function.Function<Matchable.CheckValue1<T,R>,Matchable.CheckValue1<T,R>> secondary, java.util.function.Function<Matchable.CheckValue1<java.lang.Throwable,R>,Matchable.CheckValue1<java.lang.Throwable,R>> primary, java.util.function.Supplier<? extends R> otherwise)
public <R> FutureW<R> patternMatch(java.util.function.Function<Matchable.CheckValues<T,R>,Matchable.CheckValues<T,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<T>
case1
- Function to generate a case (or chain of cases as a single case)otherwise
- Value if supplied case doesn't matchpublic T get()
get
in interface Convertable<T>
get
in interface java.util.function.Supplier<T>
public boolean isSuccess()
public boolean isFailed()
public java.util.Iterator<T> iterator()
iterator
in interface Convertable<T>
iterator
in interface java.lang.Iterable<T>
public ReactiveSeq<T> stream()
public <R> FutureW<R> flatMap(java.util.function.Function<? super T,? extends FutureW<? extends R>> mapper)
public <R> FutureW<R> flatMapCf(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<? extends R>> mapper)
public FutureW<T> toFutureW()
toFutureW
in interface Convertable<T>
public java.util.concurrent.CompletableFuture<T> toCompletableFuture()
toCompletableFuture
in interface Convertable<T>
public java.util.concurrent.CompletableFuture<T> toCompletableFutureAsync()
toCompletableFutureAsync
in interface Convertable<T>
public java.util.concurrent.CompletableFuture<T> toCompletableFutureAsync(java.util.concurrent.Executor exec)
toCompletableFutureAsync
in interface Convertable<T>
exec
- Executor to asyncrhonously populate the CompletableFuturepublic <R> FutureW<R> visit(java.util.function.Function<? super T,R> success, java.util.function.Function<java.lang.Throwable,R> failure)
public <U> FutureW<U> cast(java.lang.Class<U> type)
Functor
ClassCastException
.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)public <R> FutureW<R> trampoline(java.util.function.Function<? super T,? 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<T>
public java.lang.String toString()
toString
in class java.lang.Object
public static <T> FutureW<T> ofResult(T result)
public static <T> FutureW<T> ofError(java.lang.Throwable error)
public Maybe<T> filter(java.util.function.Predicate<? super T> fn)
filter
in interface Filterable<T>
public <U> Maybe<U> ofType(java.lang.Class<U> type)
Filterable
ofType
in interface Filterable<T>
public Maybe<T> filterNot(java.util.function.Predicate<? super T> fn)
filterNot
in interface Filterable<T>
public Maybe<T> notNull()
notNull
in interface Filterable<T>
public java.util.Optional<T> toOptional()
toOptional
in interface Convertable<T>