(Object promisesObj)
| 586 | public static CompletableFuture<List<Object>> promiseAll(Object promisesObj) { return PromiseAll(promisesObj); } |
| 587 | |
| 588 | public static CompletableFuture<List<Object>> PromiseAll(Object promisesObj) { |
| 589 | List<?> promises = (List<?>) promisesObj; |
| 590 | List<CompletableFuture<Object>> futures = new ArrayList<>(); |
| 591 | for (Object p : promises) { |
| 592 | if (p instanceof CompletableFuture) { |
| 593 | futures.add((CompletableFuture<Object>) p); |
| 594 | } |
| 595 | } |
| 596 | return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) |
| 597 | .thenApply(v -> { |
| 598 | List<Object> out = new ArrayList<>(futures.size()); |
| 599 | for (CompletableFuture<Object> f : futures) { |
| 600 | try { |
| 601 | out.add(f.get()); |
| 602 | } catch (InterruptedException | ExecutionException e) { |
| 603 | throw new RuntimeException(e); |
| 604 | } |
| 605 | } |
| 606 | return out; |
| 607 | }); |
| 608 | } |
| 609 | |
| 610 | public static Object toStringOrNull(Object value) { |
| 611 | if (value == null) return null; |
no test coverage detected