I have the following code where i have a single employee object with multiple roles. i want to split this single employee object into multiple employee objects with each object have just ONE role.
public class Employee {
private String empId;
private String empName;
private List<String> empRoles;
}
Now i have a method with return type List
public List<Employee> splitEmployeObj(Employee emp) {
// code logic goes here
}
// sample input : { empId:'123',empName:'john',empRoles:['Developer','Tester'] }
// sample output : [ { empId:'123', empName:'john',empRoles : ['Developer'] },
{ empId:'123', empName:'john',empRoles : ['Tester']]
can someone help with an efficient java8 solution.