Persona persona = new Persona.Builder()
.withCedula("7-7-7")
.withNombre("Aristides")
.withEdad(5)
.build();
public class Persona {
private String cedula;
private String nombre;
private Integer edad;
public Persona() {
}
public Persona(String cedula, String nombre, Integer edad) {
this.cedula = cedula;
this.nombre = nombre;
this.edad = edad;
}
public static class Builder {
private String cedula;
private String nombre;
private Integer edad;
public Builder withCedula(String cedula) {
this.cedula = cedula;
return this;
}
public Builder withNombre(String nombre) {
this.nombre = nombre;
return this;
}
public Builder withEdad(Integer edad) {
this.edad = edad;
return this;
}
public Persona build() {
return new Persona(cedula, nombre, edad);
}
}
}