Is there a way to simplify filter using stream? Or for it to be shorter or optimized? I'm not quite sure if using a for loop would be better to use in this scenario.
I'm just trying to separate the failed and the success messages using the failedIds.
Here is my code
List<Message> successMessages = messageList.stream()
.filter(message -> !failedMessageIds.contains(message.getId()))
.collect(Collectors.toList());
List<Message> failedMessages = messageList.stream()
.filter(message -> failedMessageIds.contains(message.getId()))
.collect(Collectors.toList());
Thank you!