I have the following classes:
class Employee
{
private String name;
private List<Address> addresses;
//...
//Getters and setters for all fields
}
public class Address
{
private String city;
private Timestamp startDate;
private Timestamp endDate;
private String typeOfResidence;
private String businessCode;
private String businessType;
//...
//Getters and setters for all the fields
}
Now I have an employee object which has list of addresses. Based on businessCode, I need to populate businessType.
The businessCode is already populated.
I have a function
public String public getBusinessType(String businessCode){
...
business logic...
return businessType;
}
Now please help to update businessType field in each address element.
I am trying using
List<Address> l = employee.getAddress();
IntStream.range(0, l.size).forEach();
But not sure how to call getBusinessType for each address element and update the field in each address element.
employee.getAddress().forEach(a->a.setBusinessType(...));