There is an abstract class Man, from which the class Worker is inherited. For the Employee class, I create my Builder:
Example:
public abstract class Human { private long id; private Gender gender; private String firstName; private String lastName; public Human() { super(); } public Human(long id, Gender gender, String firstName, String lastName) { this.setId(id); this.gender = gender; this.firstName = firstName; this.lastName = lastName; } } public class EmployeeHuman extends Human { private long id; private Company company; private Appointment appointment; EmployeeHuman() { super(); } EmployeeHuman(final EmployeeHumanBuilder employeeHumanBuilder) { super(employeeHumanBuilder.getId(), employeeHumanBuilder.getGender(), employeeHumanBuilder.getFirstName(), employeeHumanBuilder.getLastName()); this.id = employeeHumanBuilder.getId(); this.company = employeeHumanBuilder.getCompany(); this.appointment = employeeHumanBuilder.getAppointment(); } } public class EmployeeHumanBuilder { private long id; private Gender gender; private String firstName; private String lastName; private Company company; private Appointment appointment; public EmployeeHumanBuilder id(final long id) { this.id = id; return this; } public EmployeeHumanBuilder gender(final Gender gender) { this.gender = gender; return this; } public EmployeeHumanBuilder firstName(final String firstName) { this.firstName = firstName; return this; } public EmployeeHumanBuilder lastName(final String lastName) { this.lastName = lastName; return this; } public EmployeeHumanBuilder company(final Company company) { this.company = company; return this; } public EmployeeHumanBuilder appointment(final Appointment appointment) { this.appointment = appointment; return this; } public long getId() { return id; } public Gender getGender() { return gender; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public Company getCompany() { return company; } public Appointment getAppointment() { return appointment; } public EmployeeHuman build() { return new EmployeeHuman(this); } } Question: Is the Pattern Builder implemented correctly? Is he needed here or is this grief from the mind?