'filter the objects from nested collection? [duplicate]
DeviceType.java
private String Id;
private List<DeviceTelemetry> telemetries = new ArrayList<>()
//Getter Setter
DeviceTelemetry.java (Enum Class)
private String name;
private String description;
//Getter Setter
I want to fetch all DeviceType Id , which have DeviceTelemetry name start with "System"(String).
I did something like this:-
List<DeviceType> filteredStartWithDeviceType =deviceTypes.stream().
filter(f -> f.getTelemetries().stream()
.anyMatch(g -> g.getName().startsWith("System"))).collect(Collectors.toList());
Can Anyone tell me how can I get DeviceType Id from this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
