-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPersonBean.java
55 lines (49 loc) · 1.47 KB
/
PersonBean.java
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
package com.doing.more.java.example;
import java.io.Serializable;
public class PersonBean implements Serializable{
private String firstName;
private String lastName;
private int age;
public PersonBean() {
}
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return this.lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getAge() {
return this.age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
PersonBean that = (PersonBean) o;
if (this.age != that.age) return false;
if (!this.firstName.equals(that.firstName)) return false;
return this.lastName.equals(that.lastName);
}
@Override
public int hashCode() {
int result = this.firstName.hashCode();
result = 31 * result + this.lastName.hashCode();
result = 31 * result + this.age;
return result;
}
//this bean has an OPTIONAL constructor that sets all the values
public PersonBean(String firstName, String lastName, int age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}
}