Created
December 17, 2017 15:20
-
-
Save Jayasagar/3f9e227addd888607a36808ad9db961a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Map<String, Map<Thing, Boolean>> consumerWithEachDeviceStatus = consumerList | |
| .stream() | |
| .flatMap(consumer -> consumer.getThings() | |
| .stream() | |
| .map(thing -> new AbstractMap.SimpleImmutableEntry<>(consumer.getName(), thing)) | |
| ) | |
| .collect(Collectors.groupingBy(entry -> entry.getKey(), | |
| Collectors.toMap(AbstractMap.SimpleImmutableEntry::getValue, entry -> entry.getValue().isRunning()))); | |
| System.out.println(consumerWithEachDeviceStatus); | |
| //Output: {Bob={Thing(name=AgriFieldSensor)=true, Thing(name=EyeVirusDetector)=true, Thing(name=Bulb)=true, Thing(name=MotionDetector)=true}, Satti={Thing(name=AgriFieldSensor)=true, Thing(name=MotionDetector)=true}, Sri={Thing(name=EyeVirusDetector)=true, Thing(name=Bulb)=true}, Malli={Thing(name=Bulb)=true, Thing(name=MotionDetector)=true}} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment