I have deriving two separate groups from a list, error data and error free data:
List<ProductHolder> errorOnes = holderList.stream()
.filter(holder-> (holder.getRecord().isX() || holder.getRecord().isY()))
.collect(Collectors.toList());
List<ProductHolder> nonErrorOnes = holderList.stream()
.filter(holder-> (!holder.getRecord().isX() && !holder.getRecord().isY()))
.collect(Collectors.toList());
The above has multiple calls to .stream()
.
Is there a way I can partition the above into separate lists using single call to .stream()
? Is there a performance gain in doing so?
how to then access these data? I presume I need to hold use a Map?