-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneratedCode.java
More file actions
68 lines (52 loc) · 1.93 KB
/
GeneratedCode.java
File metadata and controls
68 lines (52 loc) · 1.93 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
public class Hum {
private Integer id;
private Double temp;
private Double hum;
private Date createTime; // 生成字段声明代码
public Hum(Integer id, Double temp, Double hum, Date createTime) {
this.id = id;
this.temp = temp;
this.hum = hum;
this.createTime = createTime; // 生成参数赋值语句
// 编写其他构造器逻辑
}
public Integer getId() { return this.id; }
public Double getTemp() { return this.temp; }
public Double getHum() { return this.hum; }
public Date getCreateTime() { return this.createTime; } // 生成 getter 方法代码
public void setId(Integer id) { this.id = id; }
public void setTemp(Double temp) { this.temp = temp; }
public void setHum(Double hum) { this.hum = hum; }
public void setCreateTime(Date createTime) { this.createTime = createTime; } // 生成 setter 方法代码
@Override
public String toString() {
try {
return JsonUtil.toJsonString(this);
} catch (IOException e) {
throw new RuntimeException(e);
}
} // 生成 toString() 方法代码
public static Builder builder() {
return new Builder();
}
public static class Builder {
private Integer id;
private Double temp;
private Double hum;
private Date createTime; // 生成 Builder 类的字段声明代码
public Builder() {}
public Builder id(Integer id) { this.id = id; return this; }
public Builder temp(Double temp) { this.temp = temp; return this; }
public Builder hum(Double hum) { this.hum = hum; return this; }
public Builder createTime(Date createTime) { this.createTime = createTime; return this; } // 生成 Builder 类的 setter 方法代码
public Hum build() {
Hum instance = new Hum();
this.id = builder.id;
this.temp = builder.temp;
this.hum = builder.hum;
this.createTime = builder.createTime; // 生成构建实例时的赋值语句
return instance;
}
} // 生成 Builder 类代码 // 生成 Builder 类代码
// 编写其他类逻辑
}