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 public int getPrimaryKey() {
130 return _listTypeId;
131 }
132
133 public void setPrimaryKey(int primaryKey) {
134 setListTypeId(primaryKey);
135 }
136
137 public Serializable getPrimaryKeyObj() {
138 return _listTypeId;
139 }
140
141 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
142 setPrimaryKey(((Integer)primaryKeyObj).intValue());
143 }
144
145 public Class<?> getModelClass() {
146 return ListType.class;
147 }
148
149 public String getModelClassName() {
150 return ListType.class.getName();
151 }
152
153 @Override
154 public Map<String, Object> getModelAttributes() {
155 Map<String, Object> attributes = new HashMap<String, Object>();
156
157 attributes.put("listTypeId", getListTypeId());
158 attributes.put("name", getName());
159 attributes.put("type", getType());
160
161 return attributes;
162 }
163
164 @Override
165 public void setModelAttributes(Map<String, Object> attributes) {
166 Integer listTypeId = (Integer)attributes.get("listTypeId");
167
168 if (listTypeId != null) {
169 setListTypeId(listTypeId);
170 }
171
172 String name = (String)attributes.get("name");
173
174 if (name != null) {
175 setName(name);
176 }
177
178 String type = (String)attributes.get("type");
179
180 if (type != null) {
181 setType(type);
182 }
183 }
184
185 @JSON
186 public int getListTypeId() {
187 return _listTypeId;
188 }
189
190 public void setListTypeId(int listTypeId) {
191 _listTypeId = listTypeId;
192 }
193
194 @JSON
195 public String getName() {
196 if (_name == null) {
197 return StringPool.BLANK;
198 }
199 else {
200 return _name;
201 }
202 }
203
204 public void setName(String name) {
205 _columnBitmask = -1L;
206
207 _name = name;
208 }
209
210 @JSON
211 public String getType() {
212 if (_type == null) {
213 return StringPool.BLANK;
214 }
215 else {
216 return _type;
217 }
218 }
219
220 public void setType(String type) {
221 _columnBitmask |= TYPE_COLUMN_BITMASK;
222
223 if (_originalType == null) {
224 _originalType = _type;
225 }
226
227 _type = type;
228 }
229
230 public String getOriginalType() {
231 return GetterUtil.getString(_originalType);
232 }
233
234 public long getColumnBitmask() {
235 return _columnBitmask;
236 }
237
238 @Override
239 public ListType toEscapedModel() {
240 if (_escapedModel == null) {
241 _escapedModel = (ListType)ProxyUtil.newProxyInstance(_classLoader,
242 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
243 }
244
245 return _escapedModel;
246 }
247
248 @Override
249 public Object clone() {
250 ListTypeImpl listTypeImpl = new ListTypeImpl();
251
252 listTypeImpl.setListTypeId(getListTypeId());
253 listTypeImpl.setName(getName());
254 listTypeImpl.setType(getType());
255
256 listTypeImpl.resetOriginalValues();
257
258 return listTypeImpl;
259 }
260
261 public int compareTo(ListType listType) {
262 int value = 0;
263
264 value = getName().compareToIgnoreCase(listType.getName());
265
266 if (value != 0) {
267 return value;
268 }
269
270 return 0;
271 }
272
273 @Override
274 public boolean equals(Object obj) {
275 if (obj == null) {
276 return false;
277 }
278
279 ListType listType = null;
280
281 try {
282 listType = (ListType)obj;
283 }
284 catch (ClassCastException cce) {
285 return false;
286 }
287
288 int primaryKey = listType.getPrimaryKey();
289
290 if (getPrimaryKey() == primaryKey) {
291 return true;
292 }
293 else {
294 return false;
295 }
296 }
297
298 @Override
299 public int hashCode() {
300 return getPrimaryKey();
301 }
302
303 @Override
304 public void resetOriginalValues() {
305 ListTypeModelImpl listTypeModelImpl = this;
306
307 listTypeModelImpl._originalType = listTypeModelImpl._type;
308
309 listTypeModelImpl._columnBitmask = 0;
310 }
311
312 @Override
313 public CacheModel<ListType> toCacheModel() {
314 ListTypeCacheModel listTypeCacheModel = new ListTypeCacheModel();
315
316 listTypeCacheModel.listTypeId = getListTypeId();
317
318 listTypeCacheModel.name = getName();
319
320 String name = listTypeCacheModel.name;
321
322 if ((name != null) && (name.length() == 0)) {
323 listTypeCacheModel.name = null;
324 }
325
326 listTypeCacheModel.type = getType();
327
328 String type = listTypeCacheModel.type;
329
330 if ((type != null) && (type.length() == 0)) {
331 listTypeCacheModel.type = null;
332 }
333
334 return listTypeCacheModel;
335 }
336
337 @Override
338 public String toString() {
339 StringBundler sb = new StringBundler(7);
340
341 sb.append("{listTypeId=");
342 sb.append(getListTypeId());
343 sb.append(", name=");
344 sb.append(getName());
345 sb.append(", type=");
346 sb.append(getType());
347 sb.append("}");
348
349 return sb.toString();
350 }
351
352 public String toXmlString() {
353 StringBundler sb = new StringBundler(13);
354
355 sb.append("<model><model-name>");
356 sb.append("com.liferay.portal.model.ListType");
357 sb.append("</model-name>");
358
359 sb.append(
360 "<column><column-name>listTypeId</column-name><column-value><![CDATA[");
361 sb.append(getListTypeId());
362 sb.append("]]></column-value></column>");
363 sb.append(
364 "<column><column-name>name</column-name><column-value><![CDATA[");
365 sb.append(getName());
366 sb.append("]]></column-value></column>");
367 sb.append(
368 "<column><column-name>type</column-name><column-value><![CDATA[");
369 sb.append(getType());
370 sb.append("]]></column-value></column>");
371
372 sb.append("</model>");
373
374 return sb.toString();
375 }
376
377 private static ClassLoader _classLoader = ListType.class.getClassLoader();
378 private static Class<?>[] _escapedModelInterfaces = new Class[] {
379 ListType.class
380 };
381 private int _listTypeId;
382 private String _name;
383 private String _type;
384 private String _originalType;
385 private long _columnBitmask;
386 private ListType _escapedModel;
387 }