-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFieldV3.java
More file actions
37 lines (30 loc) · 906 Bytes
/
Copy pathFieldV3.java
File metadata and controls
37 lines (30 loc) · 906 Bytes
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
package reflection;
import reflection.data.Team;
import reflection.data.User;
public class FieldV3 {
public static void main(String[] args) {
User user = new User("id1", null, null);
Team team = new Team("team1", null);
System.out.println("==== before ====");
System.out.println("user = " + user);
System.out.println("team = " + team);
if(user.getId() == null){
user.setId("");
}
if(user.getName() == null){
user.setName("");
}
if(user.getAge() == null){
user.setAge(0);
}
if(team.getId() == null ){
team.setId("");
}
if(team.getName() == null){
team.setName("");
}
System.out.println(" ==== after ==== ");
System.out.println("user = " + user);
System.out.println("team = " + team);
}
}