Repository navigation
Expand file tree
/
Copy pathUser.java
More file actions
92 lines (71 loc) · 2.26 KB
/
Copy pathUser.java
File metadata and controls
92 lines (71 loc) · 2.26 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.javarush.task.task20.task2002;
import java.util.Date;
public class User {
private String firstName;
private String lastName;
private Date birthDate;
private boolean isMale;
private Country country;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
public boolean isMale() {
return isMale;
}
public void setMale(boolean male) {
isMale = male;
}
public Country getCountry() {
return country;
}
public void setCountry(Country country) {
this.country = country;
}
public static enum Country {
UKRAINE("Ukraine"),
RUSSIA("Russia"),
OTHER("Other");
private String name;
private Country(String name) {
this.name = name;
}
public String getDisplayedName() {
return this.name;
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
if (isMale != user.isMale) return false;
if (firstName != null ? !firstName.equals(user.firstName) : user.firstName != null) return false;
if (lastName != null ? !lastName.equals(user.lastName) : user.lastName != null) return false;
if (birthDate != null ? !birthDate.equals(user.birthDate) : user.birthDate != null) return false;
return country == user.country;
}
@Override
public int hashCode() {
int result = firstName != null ? firstName.hashCode() : 0;
result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
result = 31 * result + (birthDate != null ? birthDate.hashCode() : 0);
result = 31 * result + (isMale ? 1 : 0);
result = 31 * result + (country != null ? country.hashCode() : 0);
return result;
}
}