I am having two objects Employee and Customer having similar object properties like name, id etc I want to populate objects vice versa from List<Employee> empList to List<Customer> customerList and vice versa.
List<Employee> empList=getEmployeeList();
// Here is what i am trying so far
List<Customer> cutomers=new ArrayList<Customer>();
empList.foreach(e->{
Customer customer = new Customer();
customer.setCustomerName(e.getEmploueeName());//etc
customers.add(cutomer);
})
// what i am looking for
List<Customer> customers=Utils.getObject(empList,Customer.class);
Here is java POJO
class Employee {
private String employeeName;
private int age;
private EmployeeDetails details;
}
class EmployeeDetails {
private String name;
private int salary;
}
class Customer{
private String customerName;
private int age;
private CustomerDetails details;
}
class CustomerDetails {
private String name;
private int salary;
}
Instead of populating list from employee to customer and vice versa i want to use any 3rd part library like Apache Commons