What is the difference to use this approach to standard way of creating Builder Pattern within the class:
public class MyClass {
private String name;
private String address;
private String email;
public MyClass(){}
public MyClass withName(String name) {
this.name = name;
return this;
}
public MyClass withAddress(String address) {..}
public MyClass withEmail(String email) {..}
}
MyClass clazz = new MyClass().withAddress("").withName("").withEmail(""); Effect is the same. What I've missed?
Aucun commentaire:
Enregistrer un commentaire