-
Notifications
You must be signed in to change notification settings - Fork 16
/
User.java
executable file
·141 lines (113 loc) · 2.8 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.lonepulse.robozombie.model;
/*
* #%L
* RoboZombie
* %%
* Copyright (C) 2013 - 2014 Lonepulse
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.Serializable;
/**
* <p>A mock entity which is used to test the deserializers and the response processor chain.</p>
*
* <p><b>Note</b> that {@link #toString()} produces the JSON representation of this entity.</p>
*
* @version 1.1.0
* <br><br>
* @since 1.3.0
* <br><br>
* @author <a href="http://sahan.me">Lahiru Sahan Jayasinghe</a>
*/
public class User implements Serializable {
private static final long serialVersionUID = -5629006892332071122L;
private long id;
private String firstName;
private String lastName;
private int age;
private boolean immortal;
public User() {}
public User(long id, String firstName, String lastName, int age, boolean immortal) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
this.immortal = immortal;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
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 int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public boolean isImmortal() {
return immortal;
}
public void setImmortal(boolean immortal) {
this.immortal = immortal;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (id ^ (id >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
User other = (User) obj;
if (id != other.id)
return false;
return true;
}
@Override
public String toString() {
return new StringBuilder("{")
.append("\"id\":")
.append(id)
.append(", \"firstName\":\"")
.append(firstName)
.append("\", \"lastName\":\"")
.append(lastName)
.append("\", \"age\":")
.append(age)
.append(", \"immortal\":")
.append(String.valueOf(immortal))
.append("}").toString();
}
}