I have a class with (say) 50 fields. I only use a few of them per deployment of the program per user need. Is there a way to make the constructor generic yet specific to the deployment?
e.g
public class Employee{
private String id = "default";
private String empcat = "default";
private String empfam = "default";
private String phychar = "default";
private String othchar = "default";
private String shoesty = "default";
private Double shoesiz = 0.0;
private String shoesty = "default";
private Double shirsiz = 0.0;
private String shirsty = "default";
.........50 other fields..
}
"User/Customer 1" - only wants to use the program for shoe and thus instantiates the object with :
Employee obemp = new Employee("John", 11.5, Dockers); (i.e. id, shoesiz and shoesty)
User/Customer 2 - only wants to use the program for shirt and thus instantiates the object with :
Employee obemp = new Employee("John", 42, ABC); (i.e. id, shirsiz and shirsty)
User/Customer 3 - only wants to use the program for family and thus instantiates the object with :
Employee obemp = new Employee("John", "Smith"); (i.e. id, empfam)
The order of the fields during the object creation can be different - depending on the usage in the model.
Employee e = Employee.ofName("John").ofSurname("Smith").build()Employee.