Java代码
/**
* Created by baixiaobin
*/
public class User {
private final int id;
private final String name;
private final String sex;
private final String des;
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getSex() {
return sex;
}
public String getDes() {
return des;
}
public static class Builder {
private final int id;
private final String name;
private String sex;
private String des;
public User build() { 下载
return new User(this);
}
/**
* id 主键id
* name 名称
*/
public Builder(int id, String name) {
this.id = id;
this.name = name;
}
public Builder sex(String sex) {
this.sex = sex;
return this;
}
public Builder des(String des) {
this.des = des;
return this;
}
}
private User(Builder builder) {
this.id = builder.id;
this.name = builder.name;
this.des = builder.des;
this.sex = builder.sex;
}
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。