/** * Constructs a FluentFutureStream from a Stream of Future */ public static <T> FluentFutureStream<T> of(Stream<CompletableFuture<T>> completableFutureStream) { return new FluentFutureStream<>(CompletableFutureUtil.allOf(completableFutureStream)); }
/** * sort all elements of the stream by the provided {@code Comparator}. */ public FluentFutureStream<T> sorted(Comparator<T> comparator) { return FluentFutureStream.of( CompletableFutureUtil.sorted(completableFuture(), comparator)); }
@Override protected Closeable addContextToMDC(NamespaceRequest message) { return MDCBuilder.create() .addContext(MDCBuilder.ACTION, "NAMESPACE") .build(); } }
/** * Apply a transformation to all values of the underlying stream. */ public <U> FluentFutureStream<U> map(Function<T, U> function) { return FluentFutureStream.of( CompletableFutureUtil.map(completableFuture(), function)); }
/** * Apply a transformation to all value of the underlying stream. * * As the supplied transformation produces futures, we need to compose the returned values. */ public <U> FluentFutureStream<U> thenComposeOnAll(Function<T, CompletableFuture<U>> function) { return FluentFutureStream.of( CompletableFutureUtil.thenComposeOnAll(completableFuture(), function)); }
/** * For all values of the underlying stream, an action will be performed. */ public FluentFutureStream<T> performOnAll(Function<T, CompletableFuture<Void>> action) { return FluentFutureStream.of( CompletableFutureUtil.performOnAll(completableFuture(), action)); }
/** * Helper method to get the milliseconds for the given amount and unit * * @param amount * The amount for use with the unit * @param unit * The unit * @return The time in milliseconds * @throws NumberFormatException * Get thrown if an illegal unit was used */ public static long getMilliSeconds(long amount, String unit) throws NumberFormatException { return getMilliSeconds(amount, Unit.parse(unit)); }
public static <T> FluentFutureStream<T> unboxFluentFuture(FluentFutureStream<FluentFutureStream<T>> futures) { return unboxStream( unboxFuture( futures.map(FluentFutureStream::completableFuture))); }
/** * Reduces the underlying stream. Reduced value is supplied as a Future of optional, as no empty value is supplied. */ public CompletableFuture<Optional<T>> reduce(BinaryOperator<T> combiner) { return CompletableFutureUtil.reduce(combiner, completableFuture); }
@Override protected Closeable addContextToMDC(NoopRequest message) { return MDCBuilder.create() .addContext(MDCBuilder.ACTION, "NOOP") .build(); } }
/** * Apply a transformation to all values of the underlying stream. */ public <U> FluentFutureStream<U> map(Function<T, U> function) { return FluentFutureStream.of( CompletableFutureUtil.map(completableFuture(), function)); }
/** * sort all elements of the stream by the provided {@code Comparator}. */ public FluentFutureStream<T> sorted(Comparator<T> comparator) { return FluentFutureStream.of( CompletableFutureUtil.sorted(completableFuture(), comparator)); }
/** * Constructs a FluentFutureStream from a Stream of Future */ public static <T> FluentFutureStream<T> of(Stream<CompletableFuture<T>> completableFutureStream) { return new FluentFutureStream<>(CompletableFutureUtil.allOf(completableFutureStream)); }
/** * Helper method to get the milliseconds for the given amount and unit * * @param amount * The amount for use with the unit * @param unit * The unit * @return The time in milliseconds * @throws NumberFormatException * Get thrown if an illegal unit was used */ public static long getMilliSeconds(long amount, String unit) throws NumberFormatException { return getMilliSeconds(amount, Unit.parse(unit)); }
/** * Reduces the underlying stream. Reduced value is supplied as a Future of optional, as no empty value is supplied. */ public CompletableFuture<Optional<T>> reduce(BinaryOperator<T> combiner) { return CompletableFutureUtil.reduce(combiner, completableFuture); }
/** * Apply a transformation to all values of the underlying stream. */ public <U> FluentFutureStream<U> map(Function<T, U> function) { return FluentFutureStream.of( CompletableFutureUtil.map(completableFuture(), function)); }
/** * Constructs a FluentFutureStream from a Stream of Future */ public static <T> FluentFutureStream<T> of(Stream<CompletableFuture<T>> completableFutureStream) { return new FluentFutureStream<>(CompletableFutureUtil.allOf(completableFutureStream)); }