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);
    }

    private  Streams();

}