Let's say I have such object:
public class Customer {
private Integer id;
private String country;
private Integer customerId;
private String name;
private String surname;
private Date dateOfBirth;
}
and I have a List. I would like to split such list with Java streams so that I would get a list of ids List, countries List, customerIds List etc.
I know that I could do it as simple as making 6 streams such as:
List idsList = customerList.stream()
.map(Customer::getId)
.collect(Collectors.toList());
but doing it that many times that I have fields seems pretty dull. I was thinking about custom Collector but I could not come up with anything useful that would be both neat and efficient.
解决方案
For a type safe solution, you’d need to define a class holding t