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.GetterUtil;
27  import com.liferay.portal.model.UserIdMapper;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.Html;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="UserIdMapperModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>UserIdMapper</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.UserIdMapper
54   * @see com.liferay.portal.service.model.UserIdMapperModel
55   * @see com.liferay.portal.service.model.impl.UserIdMapperImpl
56   *
57   */
58  public class UserIdMapperModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "UserIdMapper";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "userIdMapperId", new Integer(Types.BIGINT) },
62              
63  
64              { "userId", new Integer(Types.BIGINT) },
65              
66  
67              { "type_", new Integer(Types.VARCHAR) },
68              
69  
70              { "description", new Integer(Types.VARCHAR) },
71              
72  
73              { "externalUserId", new Integer(Types.VARCHAR) }
74          };
75      public static final String TABLE_SQL_CREATE = "create table UserIdMapper (userIdMapperId LONG not null primary key,userId LONG,type_ VARCHAR(75) null,description VARCHAR(75) null,externalUserId VARCHAR(75) null)";
76      public static final String TABLE_SQL_DROP = "drop table UserIdMapper";
77      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
78                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserIdMapper"),
79              true);
80      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
81                  "lock.expiration.time.com.liferay.portal.model.UserIdMapper"));
82  
83      public UserIdMapperModelImpl() {
84      }
85  
86      public long getPrimaryKey() {
87          return _userIdMapperId;
88      }
89  
90      public void setPrimaryKey(long pk) {
91          setUserIdMapperId(pk);
92      }
93  
94      public Serializable getPrimaryKeyObj() {
95          return new Long(_userIdMapperId);
96      }
97  
98      public long getUserIdMapperId() {
99          return _userIdMapperId;
100     }
101 
102     public void setUserIdMapperId(long userIdMapperId) {
103         if (userIdMapperId != _userIdMapperId) {
104             _userIdMapperId = userIdMapperId;
105         }
106     }
107 
108     public long getUserId() {
109         return _userId;
110     }
111 
112     public void setUserId(long userId) {
113         if (userId != _userId) {
114             _userId = userId;
115         }
116     }
117 
118     public String getType() {
119         return GetterUtil.getString(_type);
120     }
121 
122     public void setType(String type) {
123         if (((type == null) && (_type != null)) ||
124                 ((type != null) && (_type == null)) ||
125                 ((type != null) && (_type != null) && !type.equals(_type))) {
126             _type = type;
127         }
128     }
129 
130     public String getDescription() {
131         return GetterUtil.getString(_description);
132     }
133 
134     public void setDescription(String description) {
135         if (((description == null) && (_description != null)) ||
136                 ((description != null) && (_description == null)) ||
137                 ((description != null) && (_description != null) &&
138                 !description.equals(_description))) {
139             _description = description;
140         }
141     }
142 
143     public String getExternalUserId() {
144         return GetterUtil.getString(_externalUserId);
145     }
146 
147     public void setExternalUserId(String externalUserId) {
148         if (((externalUserId == null) && (_externalUserId != null)) ||
149                 ((externalUserId != null) && (_externalUserId == null)) ||
150                 ((externalUserId != null) && (_externalUserId != null) &&
151                 !externalUserId.equals(_externalUserId))) {
152             _externalUserId = externalUserId;
153         }
154     }
155 
156     public UserIdMapper toEscapedModel() {
157         if (isEscapedModel()) {
158             return (UserIdMapper)this;
159         }
160         else {
161             UserIdMapper model = new UserIdMapperImpl();
162 
163             model.setEscapedModel(true);
164 
165             model.setUserIdMapperId(getUserIdMapperId());
166             model.setUserId(getUserId());
167             model.setType(Html.escape(getType()));
168             model.setDescription(Html.escape(getDescription()));
169             model.setExternalUserId(Html.escape(getExternalUserId()));
170 
171             model = (UserIdMapper)Proxy.newProxyInstance(UserIdMapper.class.getClassLoader(),
172                     new Class[] { UserIdMapper.class },
173                     new ReadOnlyBeanHandler(model));
174 
175             return model;
176         }
177     }
178 
179     public Object clone() {
180         UserIdMapperImpl clone = new UserIdMapperImpl();
181 
182         clone.setUserIdMapperId(getUserIdMapperId());
183         clone.setUserId(getUserId());
184         clone.setType(getType());
185         clone.setDescription(getDescription());
186         clone.setExternalUserId(getExternalUserId());
187 
188         return clone;
189     }
190 
191     public int compareTo(Object obj) {
192         if (obj == null) {
193             return -1;
194         }
195 
196         UserIdMapperImpl userIdMapper = (UserIdMapperImpl)obj;
197 
198         long pk = userIdMapper.getPrimaryKey();
199 
200         if (getPrimaryKey() < pk) {
201             return -1;
202         }
203         else if (getPrimaryKey() > pk) {
204             return 1;
205         }
206         else {
207             return 0;
208         }
209     }
210 
211     public boolean equals(Object obj) {
212         if (obj == null) {
213             return false;
214         }
215 
216         UserIdMapperImpl userIdMapper = null;
217 
218         try {
219             userIdMapper = (UserIdMapperImpl)obj;
220         }
221         catch (ClassCastException cce) {
222             return false;
223         }
224 
225         long pk = userIdMapper.getPrimaryKey();
226 
227         if (getPrimaryKey() == pk) {
228             return true;
229         }
230         else {
231             return false;
232         }
233     }
234 
235     public int hashCode() {
236         return (int)getPrimaryKey();
237     }
238 
239     private long _userIdMapperId;
240     private long _userId;
241     private String _type;
242     private String _description;
243     private String _externalUserId;
244 }