This repository has been archived by the owner on Jan 17, 2019. It is now read-only.
/
User.java
100 lines (74 loc) · 2.16 KB
/
User.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
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
93
94
95
96
97
98
99
100
package com.nurkiewicz.jdbcrepository.repositories;
import org.springframework.data.domain.Persistable;
import java.util.Date;
public class User implements Persistable<String> {
private transient boolean persisted;
private String userName;
private Date dateOfBirth;
private int reputation;
private boolean enabled;
public User(String userName, Date dateOfBirth, int reputation, boolean enabled) {
this.userName = userName;
this.dateOfBirth = dateOfBirth;
this.reputation = reputation;
this.enabled = enabled;
}
@Override
public String getId() {
return userName;
}
@Override
public boolean isNew() {
return !persisted;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public int getReputation() {
return reputation;
}
public void setReputation(int reputation) {
this.reputation = reputation;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public User withPersisted(boolean persisted) {
this.persisted = persisted;
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
if (enabled != user.enabled) return false;
if (reputation != user.reputation) return false;
if (dateOfBirth != null ? !dateOfBirth.equals(user.dateOfBirth) : user.dateOfBirth != null) return false;
return !(userName != null ? !userName.equals(user.userName) : user.userName != null);
}
@Override
public int hashCode() {
int result = userName != null ? userName.hashCode() : 0;
result = 31 * result + (dateOfBirth != null ? dateOfBirth.hashCode() : 0);
result = 31 * result + reputation;
result = 31 * result + (enabled ? 1 : 0);
return result;
}
@Override
public String toString() {
return "User(userName='" + userName + '\'' + ", dateOfBirth=" + dateOfBirth + ", reputation=" + reputation + ", enabled=" + enabled + ')';
}
}