I'm new to java8.
I have the following classes.
class User {
List<Vehicle> vehicle;
private int vehiclecount;
public List<Vehicle> getVehicle() {
return vehicle;
}
}
class Vehicle{
String vehiclename;
String vehiclecolor;
}
I am able to save this in mongo collection:
{ "_id" : ObjectId("59ca1e53a1a79607fcc9200f"), "_class" : "com.test.User",
"vechicle" : [ { "vehiclename" : "Car", "vehiclecolor" : "Blue" } ],
"count" : 1, "createdDate" : ISODate("2017-09-26T09:30:59.826Z") }
Now i pulled out the result based on spring mongo data repository. i want to iterate the above mongo collection so that i can only get the vehicle list I tried the below:
List<Vehicle> vehicle = result.stream().filter(vehicles->vehicles.getVehicle().stream().collect(Collectors.toList());
Please help im new to java8. Thanks in advance