What is the most concise way to 'backup' a state of a collection while iterating with java stream API?
For example, how could I 'implement' .backup(allRules)?
ArrayList<String> allRules = new ArrayList<>();
Set<String> businessRules = result.getRules().stream()
.map(name -> replace(name, RULES_PACKAGE_NAME, EMPTY))
.backup(allRules)
.filter(name -> !NON_BUSINESS_RULES.contains(name))
.collect(toSet());