I have List<EmployeeDetails>
which contains total list of employees among the organization.
EmployeeDetails.java
private String name;
private String designation;
//other property
I want loop over above list
and feed the element into model class which contains many types of lists
Emoloyee.java
List<Manager> manager;
List<Intern> intern;
List<TeamLead> teamLead;
List<Support> support;
Manager.java
private String name;
private String designation;
//other property
How can I feed Employee.java
by only single loop over List<EmployeeDetails>
?
I know I can use for
loop against list and create each type of list based on designation and feed to model but I am looking for a better approach where I don't want to create many list.
Is there any better approach where I can feed to model on-the-fly in single loop.
question from:
https://stackoverflow.com/questions/65877373/stream-over-a-list-to-feed-other-lists-in-java 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…