Skip to content

Commit 8d5f4c9

Browse files
处理对象
1 parent d98ea3c commit 8d5f4c9

File tree

3 files changed

+17
-121
lines changed

3 files changed

+17
-121
lines changed

src/main/java/com/bean/Address.java

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,22 @@
11
package com.bean;
22

33
import lombok.AllArgsConstructor;
4-
import lombok.Builder;
54
import lombok.Data;
65
import lombok.NoArgsConstructor;
76

8-
import java.util.Optional;
9-
107
/**
118
* @Author: EnjoyCoding
129
* @Date: 2020\3\6 0006 23:31
1310
* @Description:
1411
*/
15-
12+
@Data
13+
@AllArgsConstructor
14+
@NoArgsConstructor
1615
public class Address {
1716
private String country;
1817
private String province;
1918
private String city;
2019

21-
public Address(String country, String province, String city) {
22-
this.country = country;
23-
this.province = province;
24-
this.city = city;
25-
}
26-
27-
public Address() {
28-
}
29-
30-
public String getCountry() {
31-
return country;
32-
}
33-
34-
public void setCountry(String country) {
35-
this.country = country;
36-
}
37-
38-
public String getProvince() {
39-
return province;
40-
}
41-
42-
public void setProvince(String province) {
43-
this.province = province;
44-
}
45-
46-
public void setCity(String city) {
47-
this.city = city;
48-
}
4920

50-
// public Optional<String> getCity() {
51-
// return Optional.ofNullable(this.city);
52-
// }
5321

54-
public String getCity() {
55-
return this.city;
56-
}
5722
}

src/main/java/com/bean/LocalUser.java

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,18 @@
11
package com.bean;
22

3+
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
@Data
9+
@AllArgsConstructor
10+
@NoArgsConstructor
311
public class LocalUser {
412
private int id;
513
private String userName;
614
private String password;
715
private int age;
816

9-
public LocalUser(int id, String userName, String password, int age) {
10-
this.id = id;
11-
this.userName = userName;
12-
this.password = password;
13-
this.age = age;
14-
}
15-
16-
public int getId() {
17-
return id;
18-
}
19-
20-
public void setId(int id) {
21-
this.id = id;
22-
}
23-
24-
public String getUserName() {
25-
return userName;
26-
}
27-
28-
public void setUserName(String userName) {
29-
this.userName = userName;
30-
}
31-
32-
public String getPassword() {
33-
return password;
34-
}
35-
36-
public void setPassword(String password) {
37-
this.password = password;
38-
}
39-
40-
public int getAge() {
41-
return age;
42-
}
4317

44-
public void setAge(int age) {
45-
this.age = age;
46-
}
4718
}

src/main/java/com/bean/User.java

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,20 @@
11
package com.bean;
22

3-
import java.util.Optional;
3+
import lombok.AllArgsConstructor;
4+
import lombok.Data;
5+
import lombok.NoArgsConstructor;
46

57
/**
68
* Created by lenovo on 三月
79
*/
10+
@Data
11+
@AllArgsConstructor
12+
@NoArgsConstructor
813
public class User {
914
private String name;
1015
private String password;
1116
private String email;
1217
private Address address;
1318

14-
public Optional<Address> getAddress() {
15-
return Optional.ofNullable(address);
16-
}
1719

18-
19-
public User() {
20-
}
21-
22-
public User(String name, String password, String email) {
23-
this.name = name;
24-
this.password = password;
25-
this.email = email;
26-
}
27-
28-
public String getName() {
29-
return name;
30-
}
31-
32-
public void setName(String name) {
33-
this.name = name;
34-
}
35-
36-
public String getPassword() {
37-
return password;
38-
}
39-
40-
public void setPassword(String password) {
41-
this.password = password;
42-
}
43-
44-
public String getEmail() {
45-
return email;
46-
}
47-
48-
public void setEmail(String email) {
49-
this.email = email;
50-
}
51-
52-
@Override
53-
public String toString() {
54-
return "User{" +
55-
"name='" + name + '\'' +
56-
", password='" + password + '\'' +
57-
", email='" + email + '\'' +
58-
'}';
59-
}
6020
}

0 commit comments

Comments
 (0)