I have following code
Map<Long,String> timeMap= new HashMap<>();
Map<Boolean, List<Map.Entry<Long,String>>> output= timeMap.entrySet().parallelStream()
.filter(map -> map.getKey()-Instant.now().toEpochMilli()>120000)
.collect(Collectors.groupingBy(o -> o.getKey()<600000));
I want my output to be a map nested map
Map<Boolean, List<Map.Entry<Long,String>>> output --> Map<Boolean, Map<Long,String>> output
Could someone help me to write a BiFunction to achieve this.
Currently I'm using following approach to generate the output.
Map<Long, String> trueMap = output.get(true).stream()
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
Map<Long, String> falseMap = output.get(false).stream()
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
Map<Boolean,Map<Long,String>> booleanMapMap = new HashMap<>();
booleanMapMap.put(true,trueMap);
booleanMapMap.put(false,falseMap);