1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| public class Product { private String attribute1; private String attribute2; private String attribute3;
private Product(Builder builder) { this.attribute1 = builder.attribute1; this.attribute2 = builder.attribute2; this.attribute3 = builder.attribute3; }
public static class Builder { private String attribute1; private String attribute2; private String attribute3;
public Builder attribute1(String value) { this.attribute1 = value; return this; }
public Builder attribute2(String value) { this.attribute2 = value; return this; }
public Builder attribute3(String value) { this.attribute3 = value; return this; }
public Product build() { return new Product(this); } } }
|