1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.promotego.beans;
20
21 import java.util.List;
22 import java.util.TimeZone;
23
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.OneToMany;
27 import javax.persistence.Table;
28 import javax.persistence.Transient;
29
30 import org.apache.commons.lang.builder.EqualsBuilder;
31 import org.apache.commons.lang.builder.HashCodeBuilder;
32
33 @Entity
34 @Table(name="promotego_user")
35 public class User extends BeanSupport<User>
36 {
37 /***
38 * Members to exclude from equals and hashCode calculations
39 */
40 private static final String[] s_equalsExcludes = new String[] {"m_addresses", "m_offeredGames", "m_locations"};
41 private String m_username;
42 private String m_cryptedPassword;
43 private String m_emailAddress;
44 private boolean m_validated;
45 private List<Address> m_addresses;
46 private List<OfferedGame> m_offeredGames;
47 private List<Location> m_locations;
48 private TimeZone m_timeZone;
49
50 @Column(unique=true,nullable=false)
51 public String getUsername()
52 {
53 return m_username;
54 }
55
56 public void setUsername(String username)
57 {
58 m_username = username;
59 }
60
61 @Column(unique=true,nullable=false)
62 public String getEmailAddress()
63 {
64 return m_emailAddress;
65 }
66
67 public void setEmailAddress(String emailAddress)
68 {
69 m_emailAddress = emailAddress;
70 }
71
72 public String getCryptedPassword()
73 {
74 return m_cryptedPassword;
75 }
76
77 public void setCryptedPassword(String password)
78 {
79 m_cryptedPassword = password;
80 }
81
82 public boolean isValidated()
83 {
84 return m_validated;
85 }
86
87 public void setValidated(boolean validated)
88 {
89 m_validated = validated;
90 }
91
92 @OneToMany(mappedBy="user")
93 public List<Address> getAddresses()
94 {
95 return m_addresses;
96 }
97
98 public void setAddresses(List<Address> addresses)
99 {
100 m_addresses = addresses;
101 }
102
103 @OneToMany(mappedBy="offerer")
104 public List<OfferedGame> getOfferedGames()
105 {
106 return m_offeredGames;
107 }
108
109 public void setOfferedGames(List<OfferedGame> offeredGames)
110 {
111 m_offeredGames = offeredGames;
112 }
113
114 @Override
115 public boolean equals(Object anotherObject)
116 {
117
118
119 return EqualsBuilder.reflectionEquals(this, anotherObject, s_equalsExcludes);
120 }
121
122 @Override
123 public int hashCode()
124 {
125
126
127 return HashCodeBuilder.reflectionHashCode(this, s_equalsExcludes);
128 }
129
130 @Override
131 public String toString()
132 {
133 return "User[" + getId() + "]";
134 }
135
136 @OneToMany(mappedBy="owner")
137 public List<Location> getLocations()
138 {
139 return m_locations;
140 }
141
142 public void setLocations(List<Location> locations)
143 {
144 m_locations = locations;
145 }
146
147 @Transient
148 public TimeZone getTimeZone()
149 {
150 return m_timeZone;
151 }
152
153 public void setTimeZone(TimeZone timeZone)
154 {
155 m_timeZone = timeZone;
156 }
157 }