Assuming transmission is extraordinary, this may be feasible.
List<String> dataCollection = Arrays.asList("FOO", "hello", "VALID", "123", "BAR", "bla");
Set<String> someValues = new HashSet<>(Arrays.asList("FOO", "BAR"));
Predicate<String> firstPredicate = string -> !someValues.contains(string);
Predicate<String> secondPredicate = string -> string.chars().noneMatch(c -> c>100);
List<String> result;
if(!logger.isLoggable(Level.WARNING)) {
result = dataCollection.stream()
.filter(firstPredicate)
.filter(secondPredicate)
.collect(Collectors.toList());
}
else {
Map<Boolean, List<String>> map = dataCollection.stream()
.collect(Collectors.partitioningBy(firstPredicate));
if(!map.get(false).isEmpty())
logger.log(Level.WARNING, "Skipped data {0} because of ...#1", map.get(false));
map = map.get(true).stream()
.collect(Collectors.partitioningBy(secondPredicate));
if(!map.get(false).isEmpty())
logger.log(Level.WARNING, "Skipped data {0} because of ...#2", map.get(false));
result = map.get(true);
}
API java.util.logging
- , , . , , , . , , ,
Sep 26, 2017 11:00:46 AM LoggingExample main
WARNUNG: Skipped data [FOO, BAR] because of ...#1
Sep 26, 2017 11:00:46 AM LoggingExample main
WARNUNG: Skipped data [hello, bla] because of ...#2
[VALID, 123]
, .