class Streams {

    @NotNull
    public static <S, T> Stream<ResultWrapper<T>> parallelize(
            @NotNull Collection<S> source,
            @NotNull Function<S, Supplier<T>> mapper
    ) {
        // operations will be executed in parallel
        List<CompletableFuture<ResultWrapper<T>>> results = source.stream()
                .map(s -> CompletableFuture.supplyAsync(new ResultSupplier<>(mapper.apply(s)), parallelExecutor))
                .collect(ImmutableList.toImmutableList());

        return collect(results);
    }

}

class StreamsTest {

    @Test
    public void parallelizeSupplier() {

        assertEquals((long) Streams.parallelize(3, () -> 42L)
                .filter(r -> !r.hasError())
                .map(ResultWrapper::getResult)
                .reduce(0L, (a, b) -> a + b), 126L);
    }

}