Cannot convert String to Builder Class Error while implementing builder Pattern. Please let me know what i am doing wrong and where. Thanks.
package BuilderDesignPattern;
public class Employee {
private final int id;
private String Name;
private String Address;
private Employee(EmployeeBuilder empB){
// Getting error at this line type mismatch cannot convert string to Employee.EmployeeBuilder.
this.id = empB.getId();
this.Name = empB.getName();
this.Address = empB.getAddress();
}
public static class EmployeeBuilder{
private int id;
private String Name;
private String Address;
public EmployeeBuilder setId(int id) {
this.id = id;
return this;
}
public EmployeeBuilder setName(String name) {
Name = name;
return this;
}
public EmployeeBuilder setAddress(String address) {
Address = address;
return this;
}
public EmployeeBuilder getId() {
return this;
}
public EmployeeBuilder getName() {
return this;
}
public EmployeeBuilder getAddress() {
return this;
}
public Employee build(){
return new Employee(this);
}
}
}
Aucun commentaire:
Enregistrer un commentaire