code: public static <T> CompletableFuture<List<T>> filter(List<T> input, Function<T, CompletableFuture<Boolean>> predicate) {
          Preconditions.checkNotNull(input);
  
          val allFutures = input.stream().collect(Collectors.toMap(key -> key, predicate::apply));
          return Futures
                  .allOf(allFutures.values())
                  .thenApply(ignored ->
                          allFutures.entrySet()
                                    .stream()
                                    .filter(e -> e.getValue().join())
                                    .map(Map.Entry::getKey).collect(Collectors.toList())
                  );
      }
docs: Filter that takes a predicate that evaluates in future and returns the filtered list that evaluates in future.
  
  @param input     Input list.
  @param predicate Predicate that evaluates in the future.
  @param <T>       Type parameter.
  @return List that evaluates in future.