1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.model.EmailAddress;
29  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.util.Html;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.Date;
40  
41  /**
42   * <a href="EmailAddressModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>EmailAddress</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.EmailAddress
57   * @see com.liferay.portal.service.model.EmailAddressModel
58   * @see com.liferay.portal.service.model.impl.EmailAddressImpl
59   *
60   */
61  public class EmailAddressModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "EmailAddress";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "emailAddressId", new Integer(Types.BIGINT) },
65              
66  
67              { "companyId", new Integer(Types.BIGINT) },
68              
69  
70              { "userId", new Integer(Types.BIGINT) },
71              
72  
73              { "userName", new Integer(Types.VARCHAR) },
74              
75  
76              { "createDate", new Integer(Types.TIMESTAMP) },
77              
78  
79              { "modifiedDate", new Integer(Types.TIMESTAMP) },
80              
81  
82              { "classNameId", new Integer(Types.BIGINT) },
83              
84  
85              { "classPK", new Integer(Types.BIGINT) },
86              
87  
88              { "address", new Integer(Types.VARCHAR) },
89              
90  
91              { "typeId", new Integer(Types.INTEGER) },
92              
93  
94              { "primary_", new Integer(Types.BOOLEAN) }
95          };
96      public static final String TABLE_SQL_CREATE = "create table EmailAddress (emailAddressId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,address VARCHAR(75) null,typeId INTEGER,primary_ BOOLEAN)";
97      public static final String TABLE_SQL_DROP = "drop table EmailAddress";
98      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
99                  "value.object.finder.cache.enabled.com.liferay.portal.model.EmailAddress"),
100             true);
101     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
102                 "lock.expiration.time.com.liferay.portal.model.EmailAddress"));
103 
104     public EmailAddressModelImpl() {
105     }
106 
107     public long getPrimaryKey() {
108         return _emailAddressId;
109     }
110 
111     public void setPrimaryKey(long pk) {
112         setEmailAddressId(pk);
113     }
114 
115     public Serializable getPrimaryKeyObj() {
116         return new Long(_emailAddressId);
117     }
118 
119     public long getEmailAddressId() {
120         return _emailAddressId;
121     }
122 
123     public void setEmailAddressId(long emailAddressId) {
124         if (emailAddressId != _emailAddressId) {
125             _emailAddressId = emailAddressId;
126         }
127     }
128 
129     public long getCompanyId() {
130         return _companyId;
131     }
132 
133     public void setCompanyId(long companyId) {
134         if (companyId != _companyId) {
135             _companyId = companyId;
136         }
137     }
138 
139     public long getUserId() {
140         return _userId;
141     }
142 
143     public void setUserId(long userId) {
144         if (userId != _userId) {
145             _userId = userId;
146         }
147     }
148 
149     public String getUserName() {
150         return GetterUtil.getString(_userName);
151     }
152 
153     public void setUserName(String userName) {
154         if (((userName == null) && (_userName != null)) ||
155                 ((userName != null) && (_userName == null)) ||
156                 ((userName != null) && (_userName != null) &&
157                 !userName.equals(_userName))) {
158             _userName = userName;
159         }
160     }
161 
162     public Date getCreateDate() {
163         return _createDate;
164     }
165 
166     public void setCreateDate(Date createDate) {
167         if (((createDate == null) && (_createDate != null)) ||
168                 ((createDate != null) && (_createDate == null)) ||
169                 ((createDate != null) && (_createDate != null) &&
170                 !createDate.equals(_createDate))) {
171             _createDate = createDate;
172         }
173     }
174 
175     public Date getModifiedDate() {
176         return _modifiedDate;
177     }
178 
179     public void setModifiedDate(Date modifiedDate) {
180         if (((modifiedDate == null) && (_modifiedDate != null)) ||
181                 ((modifiedDate != null) && (_modifiedDate == null)) ||
182                 ((modifiedDate != null) && (_modifiedDate != null) &&
183                 !modifiedDate.equals(_modifiedDate))) {
184             _modifiedDate = modifiedDate;
185         }
186     }
187 
188     public long getClassNameId() {
189         return _classNameId;
190     }
191 
192     public void setClassNameId(long classNameId) {
193         if (classNameId != _classNameId) {
194             _classNameId = classNameId;
195         }
196     }
197 
198     public long getClassPK() {
199         return _classPK;
200     }
201 
202     public void setClassPK(long classPK) {
203         if (classPK != _classPK) {
204             _classPK = classPK;
205         }
206     }
207 
208     public String getAddress() {
209         return GetterUtil.getString(_address);
210     }
211 
212     public void setAddress(String address) {
213         if (((address == null) && (_address != null)) ||
214                 ((address != null) && (_address == null)) ||
215                 ((address != null) && (_address != null) &&
216                 !address.equals(_address))) {
217             _address = address;
218         }
219     }
220 
221     public int getTypeId() {
222         return _typeId;
223     }
224 
225     public void setTypeId(int typeId) {
226         if (typeId != _typeId) {
227             _typeId = typeId;
228         }
229     }
230 
231     public boolean getPrimary() {
232         return _primary;
233     }
234 
235     public boolean isPrimary() {
236         return _primary;
237     }
238 
239     public void setPrimary(boolean primary) {
240         if (primary != _primary) {
241             _primary = primary;
242         }
243     }
244 
245     public EmailAddress toEscapedModel() {
246         if (isEscapedModel()) {
247             return (EmailAddress)this;
248         }
249         else {
250             EmailAddress model = new EmailAddressImpl();
251 
252             model.setEscapedModel(true);
253 
254             model.setEmailAddressId(getEmailAddressId());
255             model.setCompanyId(getCompanyId());
256             model.setUserId(getUserId());
257             model.setUserName(Html.escape(getUserName()));
258             model.setCreateDate(getCreateDate());
259             model.setModifiedDate(getModifiedDate());
260             model.setClassNameId(getClassNameId());
261             model.setClassPK(getClassPK());
262             model.setAddress(Html.escape(getAddress()));
263             model.setTypeId(getTypeId());
264             model.setPrimary(getPrimary());
265 
266             model = (EmailAddress)Proxy.newProxyInstance(EmailAddress.class.getClassLoader(),
267                     new Class[] { EmailAddress.class },
268                     new ReadOnlyBeanHandler(model));
269 
270             return model;
271         }
272     }
273 
274     public Object clone() {
275         EmailAddressImpl clone = new EmailAddressImpl();
276 
277         clone.setEmailAddressId(getEmailAddressId());
278         clone.setCompanyId(getCompanyId());
279         clone.setUserId(getUserId());
280         clone.setUserName(getUserName());
281         clone.setCreateDate(getCreateDate());
282         clone.setModifiedDate(getModifiedDate());
283         clone.setClassNameId(getClassNameId());
284         clone.setClassPK(getClassPK());
285         clone.setAddress(getAddress());
286         clone.setTypeId(getTypeId());
287         clone.setPrimary(getPrimary());
288 
289         return clone;
290     }
291 
292     public int compareTo(Object obj) {
293         if (obj == null) {
294             return -1;
295         }
296 
297         EmailAddressImpl emailAddress = (EmailAddressImpl)obj;
298 
299         int value = 0;
300 
301         value = DateUtil.compareTo(getCreateDate(), emailAddress.getCreateDate());
302 
303         if (value != 0) {
304             return value;
305         }
306 
307         return 0;
308     }
309 
310     public boolean equals(Object obj) {
311         if (obj == null) {
312             return false;
313         }
314 
315         EmailAddressImpl emailAddress = null;
316 
317         try {
318             emailAddress = (EmailAddressImpl)obj;
319         }
320         catch (ClassCastException cce) {
321             return false;
322         }
323 
324         long pk = emailAddress.getPrimaryKey();
325 
326         if (getPrimaryKey() == pk) {
327             return true;
328         }
329         else {
330             return false;
331         }
332     }
333 
334     public int hashCode() {
335         return (int)getPrimaryKey();
336     }
337 
338     private long _emailAddressId;
339     private long _companyId;
340     private long _userId;
341     private String _userName;
342     private Date _createDate;
343     private Date _modifiedDate;
344     private long _classNameId;
345     private long _classPK;
346     private String _address;
347     private int _typeId;
348     private boolean _primary;
349 }