Builder模式
1. builder简介
2. 代码实例
2.1 构造器重载方式
package com.wangjun.designPattern.builder;
public class Product {
private int id;
private String name;
private int type;
private float price;
public Product() {
super();
}
public Product(int id) {
super();
this.id = id;
}
public Product(int id, String name) {
super();
this.id = id;
this.name = name;
}
public Product(int id, String name, int type) {
super();
this.id = id;
this.name = name;
this.type = type;
}
public Product(int id, String name, int type, float price) {
super();
this.id = id;
this.name = name;
this.type = type;
this.price = price;
}
}2.2 JavaBeans方式
2.3 builder模式
Last updated