I have this piece of code, that I want to refactor using more the Java 8 approach, but I know that there are several options to do this: concat() Java 8 Stream API , flatMap() Java 8 Stream API , Using Guava, Using Apache Commons Collections, CompletableFuture.... I would like to know if there is a best practice to do this
List<User> users = new ArrayList<User>(); for (Restaurant restaurant : restaurants) { users.addAll(userService.getClients(restaurant.getId()) .parallelStream() .filter(us -> !alreadyNotifiedUserIds.contains(us.getId()))) .collect(Collectors.toList()); }