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 new Integer(_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().toLowerCase()
265 .compareTo(listType.getName().toLowerCase());
266
267 if (value != 0) {
268 return value;
269 }
270
271 return 0;
272 }
273
274 @Override
275 public boolean equals(Object obj) {
276 if (obj == null) {
277 return false;
278 }
279
280 ListType listType = null;
281
282 try {
283 listType = (ListType)obj;
284 }
285 catch (ClassCastException cce) {
286 return false;
287 }
288
289 int primaryKey = listType.getPrimaryKey();
290
291 if (getPrimaryKey() == primaryKey) {
292 return true;
293 }
294 else {
295 return false;
296 }
297 }
298
299 @Override
300 public int hashCode() {
301 return getPrimaryKey();
302 }
303
304 @Override
305 public void resetOriginalValues() {
306 ListTypeModelImpl listTypeModelImpl = this;
307
308 listTypeModelImpl._originalType = listTypeModelImpl._type;
309
310 listTypeModelImpl._columnBitmask = 0;
311 }
312
313 @Override
314 public CacheModel<ListType> toCacheModel() {
315 ListTypeCacheModel listTypeCacheModel = new ListTypeCacheModel();
316
317 listTypeCacheModel.listTypeId = getListTypeId();
318
319 listTypeCacheModel.name = getName();
320
321 String name = listTypeCacheModel.name;
322
323 if ((name != null) && (name.length() == 0)) {
324 listTypeCacheModel.name = null;
325 }
326
327 listTypeCacheModel.type = getType();
328
329 String type = listTypeCacheModel.type;
330
331 if ((type != null) && (type.length() == 0)) {
332 listTypeCacheModel.type = null;
333 }
334
335 return listTypeCacheModel;
336 }
337
338 @Override
339 public String toString() {
340 StringBundler sb = new StringBundler(7);
341
342 sb.append("{listTypeId=");
343 sb.append(getListTypeId());
344 sb.append(", name=");
345 sb.append(getName());
346 sb.append(", type=");
347 sb.append(getType());
348 sb.append("}");
349
350 return sb.toString();
351 }
352
353 public String toXmlString() {
354 StringBundler sb = new StringBundler(13);
355
356 sb.append("<model><model-name>");
357 sb.append("com.liferay.portal.model.ListType");
358 sb.append("</model-name>");
359
360 sb.append(
361 "<column><column-name>listTypeId</column-name><column-value><![CDATA[");
362 sb.append(getListTypeId());
363 sb.append("]]></column-value></column>");
364 sb.append(
365 "<column><column-name>name</column-name><column-value><![CDATA[");
366 sb.append(getName());
367 sb.append("]]></column-value></column>");
368 sb.append(
369 "<column><column-name>type</column-name><column-value><![CDATA[");
370 sb.append(getType());
371 sb.append("]]></column-value></column>");
372
373 sb.append("</model>");
374
375 return sb.toString();
376 }
377
378 private static ClassLoader _classLoader = ListType.class.getClassLoader();
379 private static Class<?>[] _escapedModelInterfaces = new Class[] {
380 ListType.class
381 };
382 private int _listTypeId;
383 private String _name;
384 private String _type;
385 private String _originalType;
386 private long _columnBitmask;
387 private ListType _escapedModel;
388 }