-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathUserAccount.java
377 lines (338 loc) · 12.1 KB
/
UserAccount.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/*
* Copyright 2001-present Stephen Colebourne
*
* 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.
*/
package org.joda.beans.gen;
import java.util.Date;
import java.util.Map;
import org.joda.beans.Bean;
import org.joda.beans.BeanBuilder;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaBean;
import org.joda.beans.MetaProperty;
import org.joda.beans.Property;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaBean;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
/**
* A user account class, used to demonstrate usage of Joda-Beans.
*/
@BeanDefinition
public final class UserAccount implements Bean {
/**
* The user identifier.
*/
@PropertyDefinition(validate = "notEmpty")
private String userId;
/**
* The email address.
*/
@PropertyDefinition(validate = "notEmpty")
private String emailAddress;
/**
* The number of logins.
*/
@PropertyDefinition
private int numberLogins;
/**
* The last login instant.
*/
@PropertyDefinition(validate = "notNull")
private Date lastLogin;
//------------------------- AUTOGENERATED START -------------------------
/**
* The meta-bean for {@code UserAccount}.
* @return the meta-bean, not null
*/
public static UserAccount.Meta meta() {
return UserAccount.Meta.INSTANCE;
}
static {
MetaBean.register(UserAccount.Meta.INSTANCE);
}
@Override
public UserAccount.Meta metaBean() {
return UserAccount.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the user identifier.
* @return the value of the property, not empty
*/
public String getUserId() {
return userId;
}
/**
* Sets the user identifier.
* @param userId the new value of the property, not empty
*/
public void setUserId(String userId) {
JodaBeanUtils.notEmpty(userId, "userId");
this.userId = userId;
}
/**
* Gets the the {@code userId} property.
* @return the property, not null
*/
public Property<String> userId() {
return metaBean().userId().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the email address.
* @return the value of the property, not empty
*/
public String getEmailAddress() {
return emailAddress;
}
/**
* Sets the email address.
* @param emailAddress the new value of the property, not empty
*/
public void setEmailAddress(String emailAddress) {
JodaBeanUtils.notEmpty(emailAddress, "emailAddress");
this.emailAddress = emailAddress;
}
/**
* Gets the the {@code emailAddress} property.
* @return the property, not null
*/
public Property<String> emailAddress() {
return metaBean().emailAddress().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the number of logins.
* @return the value of the property
*/
public int getNumberLogins() {
return numberLogins;
}
/**
* Sets the number of logins.
* @param numberLogins the new value of the property
*/
public void setNumberLogins(int numberLogins) {
this.numberLogins = numberLogins;
}
/**
* Gets the the {@code numberLogins} property.
* @return the property, not null
*/
public Property<Integer> numberLogins() {
return metaBean().numberLogins().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the last login instant.
* @return the value of the property, not null
*/
public Date getLastLogin() {
return lastLogin;
}
/**
* Sets the last login instant.
* @param lastLogin the new value of the property, not null
*/
public void setLastLogin(Date lastLogin) {
JodaBeanUtils.notNull(lastLogin, "lastLogin");
this.lastLogin = lastLogin;
}
/**
* Gets the the {@code lastLogin} property.
* @return the property, not null
*/
public Property<Date> lastLogin() {
return metaBean().lastLogin().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public UserAccount clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
UserAccount other = (UserAccount) obj;
return JodaBeanUtils.equal(getUserId(), other.getUserId()) &&
JodaBeanUtils.equal(getEmailAddress(), other.getEmailAddress()) &&
(getNumberLogins() == other.getNumberLogins()) &&
JodaBeanUtils.equal(getLastLogin(), other.getLastLogin());
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(getUserId());
hash = hash * 31 + JodaBeanUtils.hashCode(getEmailAddress());
hash = hash * 31 + JodaBeanUtils.hashCode(getNumberLogins());
hash = hash * 31 + JodaBeanUtils.hashCode(getLastLogin());
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(160);
buf.append("UserAccount{");
buf.append("userId").append('=').append(getUserId()).append(',').append(' ');
buf.append("emailAddress").append('=').append(getEmailAddress()).append(',').append(' ');
buf.append("numberLogins").append('=').append(getNumberLogins()).append(',').append(' ');
buf.append("lastLogin").append('=').append(JodaBeanUtils.toString(getLastLogin()));
buf.append('}');
return buf.toString();
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code UserAccount}.
*/
public static final class Meta extends DirectMetaBean {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code userId} property.
*/
private final MetaProperty<String> userId = DirectMetaProperty.ofReadWrite(
this, "userId", UserAccount.class, String.class);
/**
* The meta-property for the {@code emailAddress} property.
*/
private final MetaProperty<String> emailAddress = DirectMetaProperty.ofReadWrite(
this, "emailAddress", UserAccount.class, String.class);
/**
* The meta-property for the {@code numberLogins} property.
*/
private final MetaProperty<Integer> numberLogins = DirectMetaProperty.ofReadWrite(
this, "numberLogins", UserAccount.class, Integer.TYPE);
/**
* The meta-property for the {@code lastLogin} property.
*/
private final MetaProperty<Date> lastLogin = DirectMetaProperty.ofReadWrite(
this, "lastLogin", UserAccount.class, Date.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"userId",
"emailAddress",
"numberLogins",
"lastLogin");
/**
* Restricted constructor.
*/
private Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -836030906: // userId
return userId;
case -1070931784: // emailAddress
return emailAddress;
case 850160339: // numberLogins
return numberLogins;
case 1995610739: // lastLogin
return lastLogin;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends UserAccount> builder() {
return new DirectBeanBuilder<>(new UserAccount());
}
@Override
public Class<? extends UserAccount> beanType() {
return UserAccount.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code userId} property.
* @return the meta-property, not null
*/
public MetaProperty<String> userId() {
return userId;
}
/**
* The meta-property for the {@code emailAddress} property.
* @return the meta-property, not null
*/
public MetaProperty<String> emailAddress() {
return emailAddress;
}
/**
* The meta-property for the {@code numberLogins} property.
* @return the meta-property, not null
*/
public MetaProperty<Integer> numberLogins() {
return numberLogins;
}
/**
* The meta-property for the {@code lastLogin} property.
* @return the meta-property, not null
*/
public MetaProperty<Date> lastLogin() {
return lastLogin;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -836030906: // userId
return ((UserAccount) bean).getUserId();
case -1070931784: // emailAddress
return ((UserAccount) bean).getEmailAddress();
case 850160339: // numberLogins
return ((UserAccount) bean).getNumberLogins();
case 1995610739: // lastLogin
return ((UserAccount) bean).getLastLogin();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -836030906: // userId
((UserAccount) bean).setUserId((String) newValue);
return;
case -1070931784: // emailAddress
((UserAccount) bean).setEmailAddress((String) newValue);
return;
case 850160339: // numberLogins
((UserAccount) bean).setNumberLogins((Integer) newValue);
return;
case 1995610739: // lastLogin
((UserAccount) bean).setLastLogin((Date) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notEmpty(((UserAccount) bean).userId, "userId");
JodaBeanUtils.notEmpty(((UserAccount) bean).emailAddress, "emailAddress");
JodaBeanUtils.notNull(((UserAccount) bean).lastLogin, "lastLogin");
}
}
//-------------------------- AUTOGENERATED END --------------------------
}