001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.json.JSON;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.ProxyUtil;
021 import com.liferay.portal.kernel.util.StringBundler;
022 import com.liferay.portal.kernel.util.StringPool;
023 import com.liferay.portal.model.CacheModel;
024 import com.liferay.portal.model.ListType;
025 import com.liferay.portal.model.ListTypeModel;
026 import com.liferay.portal.model.ListTypeSoap;
027
028 import java.io.Serializable;
029
030 import java.sql.Types;
031
032 import java.util.ArrayList;
033 import java.util.HashMap;
034 import java.util.List;
035 import java.util.Map;
036
037
050 @JSON(strict = true)
051 public class ListTypeModelImpl extends BaseModelImpl<ListType>
052 implements ListTypeModel {
053
058 public static final String TABLE_NAME = "ListType";
059 public static final Object[][] TABLE_COLUMNS = {
060 { "listTypeId", Types.INTEGER },
061 { "name", Types.VARCHAR },
062 { "type_", Types.VARCHAR }
063 };
064 public static final String TABLE_SQL_CREATE = "create table ListType (listTypeId INTEGER not null primary key,name VARCHAR(75) null,type_ VARCHAR(75) null)";
065 public static final String TABLE_SQL_DROP = "drop table ListType";
066 public static final String ORDER_BY_JPQL = " ORDER BY listType.name ASC";
067 public static final String ORDER_BY_SQL = " ORDER BY ListType.name ASC";
068 public static final String DATA_SOURCE = "liferayDataSource";
069 public static final String SESSION_FACTORY = "liferaySessionFactory";
070 public static final String TX_MANAGER = "liferayTransactionManager";
071 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
072 "value.object.entity.cache.enabled.com.liferay.portal.model.ListType"),
073 true);
074 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
075 "value.object.finder.cache.enabled.com.liferay.portal.model.ListType"),
076 true);
077 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078 "value.object.column.bitmask.enabled.com.liferay.portal.model.ListType"),
079 true);
080 public static long TYPE_COLUMN_BITMASK = 1L;
081 public static long NAME_COLUMN_BITMASK = 2L;
082
083
089 public static ListType toModel(ListTypeSoap soapModel) {
090 if (soapModel == null) {
091 return null;
092 }
093
094 ListType model = new ListTypeImpl();
095
096 model.setListTypeId(soapModel.getListTypeId());
097 model.setName(soapModel.getName());
098 model.setType(soapModel.getType());
099
100 return model;
101 }
102
103
109 public static List<ListType> toModels(ListTypeSoap[] soapModels) {
110 if (soapModels == null) {
111 return null;
112 }
113
114 List<ListType> models = new ArrayList<ListType>(soapModels.length);
115
116 for (ListTypeSoap soapModel : soapModels) {
117 models.add(toModel(soapModel));
118 }
119
120 return models;
121 }
122
123 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
124 "lock.expiration.time.com.liferay.portal.model.ListType"));
125
126 public ListTypeModelImpl() {
127 }
128
129 @Override
130 public int getPrimaryKey() {
131 return _listTypeId;
132 }
133
134 @Override
135 public void setPrimaryKey(int primaryKey) {
136 setListTypeId(primaryKey);
137 }
138
139 @Override
140 public Serializable getPrimaryKeyObj() {
141 return _listTypeId;
142 }
143
144 @Override
145 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
146 setPrimaryKey(((Integer)primaryKeyObj).intValue());
147 }
148
149 @Override
150 public Class<?> getModelClass() {
151 return ListType.class;
152 }
153
154 @Override
155 public String getModelClassName() {
156 return ListType.class.getName();
157 }
158
159 @Override
160 public Map<String, Object> getModelAttributes() {
161 Map<String, Object> attributes = new HashMap<String, Object>();
162
163 attributes.put("listTypeId", getListTypeId());
164 attributes.put("name", getName());
165 attributes.put("type", getType());
166
167 return attributes;
168 }
169
170 @Override
171 public void setModelAttributes(Map<String, Object> attributes) {
172 Integer listTypeId = (Integer)attributes.get("listTypeId");
173
174 if (listTypeId != null) {
175 setListTypeId(listTypeId);
176 }
177
178 String name = (String)attributes.get("name");
179
180 if (name != null) {
181 setName(name);
182 }
183
184 String type = (String)attributes.get("type");
185
186 if (type != null) {
187 setType(type);
188 }
189 }
190
191 @JSON
192 @Override
193 public int getListTypeId() {
194 return _listTypeId;
195 }
196
197 @Override
198 public void setListTypeId(int listTypeId) {
199 _listTypeId = listTypeId;
200 }
201
202 @JSON
203 @Override
204 public String getName() {
205 if (_name == null) {
206 return StringPool.BLANK;
207 }
208 else {
209 return _name;
210 }
211 }
212
213 @Override
214 public void setName(String name) {
215 _columnBitmask = -1L;
216
217 _name = name;
218 }
219
220 @JSON
221 @Override
222 public String getType() {
223 if (_type == null) {
224 return StringPool.BLANK;
225 }
226 else {
227 return _type;
228 }
229 }
230
231 @Override
232 public void setType(String type) {
233 _columnBitmask |= TYPE_COLUMN_BITMASK;
234
235 if (_originalType == null) {
236 _originalType = _type;
237 }
238
239 _type = type;
240 }
241
242 public String getOriginalType() {
243 return GetterUtil.getString(_originalType);
244 }
245
246 public long getColumnBitmask() {
247 return _columnBitmask;
248 }
249
250 @Override
251 public ListType toEscapedModel() {
252 if (_escapedModel == null) {
253 _escapedModel = (ListType)ProxyUtil.newProxyInstance(_classLoader,
254 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
255 }
256
257 return _escapedModel;
258 }
259
260 @Override
261 public Object clone() {
262 ListTypeImpl listTypeImpl = new ListTypeImpl();
263
264 listTypeImpl.setListTypeId(getListTypeId());
265 listTypeImpl.setName(getName());
266 listTypeImpl.setType(getType());
267
268 listTypeImpl.resetOriginalValues();
269
270 return listTypeImpl;
271 }
272
273 @Override
274 public int compareTo(ListType listType) {
275 int value = 0;
276
277 value = getName().compareToIgnoreCase(listType.getName());
278
279 if (value != 0) {
280 return value;
281 }
282
283 return 0;
284 }
285
286 @Override
287 public boolean equals(Object obj) {
288 if (this == obj) {
289 return true;
290 }
291
292 if (!(obj instanceof ListType)) {
293 return false;
294 }
295
296 ListType listType = (ListType)obj;
297
298 int primaryKey = listType.getPrimaryKey();
299
300 if (getPrimaryKey() == primaryKey) {
301 return true;
302 }
303 else {
304 return false;
305 }
306 }
307
308 @Override
309 public int hashCode() {
310 return getPrimaryKey();
311 }
312
313 @Override
314 public void resetOriginalValues() {
315 ListTypeModelImpl listTypeModelImpl = this;
316
317 listTypeModelImpl._originalType = listTypeModelImpl._type;
318
319 listTypeModelImpl._columnBitmask = 0;
320 }
321
322 @Override
323 public CacheModel<ListType> toCacheModel() {
324 ListTypeCacheModel listTypeCacheModel = new ListTypeCacheModel();
325
326 listTypeCacheModel.listTypeId = getListTypeId();
327
328 listTypeCacheModel.name = getName();
329
330 String name = listTypeCacheModel.name;
331
332 if ((name != null) && (name.length() == 0)) {
333 listTypeCacheModel.name = null;
334 }
335
336 listTypeCacheModel.type = getType();
337
338 String type = listTypeCacheModel.type;
339
340 if ((type != null) && (type.length() == 0)) {
341 listTypeCacheModel.type = null;
342 }
343
344 return listTypeCacheModel;
345 }
346
347 @Override
348 public String toString() {
349 StringBundler sb = new StringBundler(7);
350
351 sb.append("{listTypeId=");
352 sb.append(getListTypeId());
353 sb.append(", name=");
354 sb.append(getName());
355 sb.append(", type=");
356 sb.append(getType());
357 sb.append("}");
358
359 return sb.toString();
360 }
361
362 @Override
363 public String toXmlString() {
364 StringBundler sb = new StringBundler(13);
365
366 sb.append("<model><model-name>");
367 sb.append("com.liferay.portal.model.ListType");
368 sb.append("</model-name>");
369
370 sb.append(
371 "<column><column-name>listTypeId</column-name><column-value><![CDATA[");
372 sb.append(getListTypeId());
373 sb.append("]]></column-value></column>");
374 sb.append(
375 "<column><column-name>name</column-name><column-value><![CDATA[");
376 sb.append(getName());
377 sb.append("]]></column-value></column>");
378 sb.append(
379 "<column><column-name>type</column-name><column-value><![CDATA[");
380 sb.append(getType());
381 sb.append("]]></column-value></column>");
382
383 sb.append("</model>");
384
385 return sb.toString();
386 }
387
388 private static ClassLoader _classLoader = ListType.class.getClassLoader();
389 private static Class<?>[] _escapedModelInterfaces = new Class[] {
390 ListType.class
391 };
392 private int _listTypeId;
393 private String _name;
394 private String _type;
395 private String _originalType;
396 private long _columnBitmask;
397 private ListType _escapedModel;
398 }