-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUser.java
More file actions
48 lines (40 loc) · 1.22 KB
/
User.java
File metadata and controls
48 lines (40 loc) · 1.22 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
package com.yurii.salimov.lesson08.task05;
/**
* @author Yuriy Salimov (yuriy.alex.salimov@gmail.com)
* @version 1.0
*/
public class User {
private final String firstName;
private final String lastName;
public User(final String firstName, final String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
@Override
public boolean equals(final Object object) {
if (object == null) {
return false;
}
if (this == object) {
return true;
}
if (getClass() != object.getClass()) {
return false;
}
final User user = (User) object;
return this.firstName != null ? this.firstName.equals(user.firstName) : user.firstName == null &&
(this.lastName != null ? this.lastName.equals(user.lastName) : user.lastName == null);
}
@Override
public int hashCode() {
int result = firstName != null ? firstName.hashCode() : 0;
result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
return result;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
}