001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020    import com.liferay.portal.kernel.json.JSON;
021    import com.liferay.portal.kernel.util.GetterUtil;
022    import com.liferay.portal.kernel.util.ProxyUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
025    import com.liferay.portal.model.CacheModel;
026    import com.liferay.portal.model.ListType;
027    import com.liferay.portal.model.ListTypeModel;
028    import com.liferay.portal.model.ListTypeSoap;
029    import com.liferay.portal.service.ServiceContext;
030    
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    
034    import java.io.Serializable;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.HashMap;
040    import java.util.List;
041    import java.util.Map;
042    
043    /**
044     * The base model implementation for the ListType service. Represents a row in the "ListType" database table, with each column mapped to a property of this class.
045     *
046     * <p>
047     * This implementation and its corresponding interface {@link ListTypeModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ListTypeImpl}.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see ListTypeImpl
052     * @see ListType
053     * @see ListTypeModel
054     * @generated
055     */
056    @JSON(strict = true)
057    @ProviderType
058    public class ListTypeModelImpl extends BaseModelImpl<ListType>
059            implements ListTypeModel {
060            /*
061             * NOTE FOR DEVELOPERS:
062             *
063             * Never modify or reference this class directly. All methods that expect a list type model instance should use the {@link ListType} interface instead.
064             */
065            public static final String TABLE_NAME = "ListType";
066            public static final Object[][] TABLE_COLUMNS = {
067                            { "mvccVersion", Types.BIGINT },
068                            { "listTypeId", Types.BIGINT },
069                            { "name", Types.VARCHAR },
070                            { "type_", Types.VARCHAR }
071                    };
072            public static final String TABLE_SQL_CREATE = "create table ListType (mvccVersion LONG default 0,listTypeId LONG not null primary key,name VARCHAR(75) null,type_ VARCHAR(75) null)";
073            public static final String TABLE_SQL_DROP = "drop table ListType";
074            public static final String ORDER_BY_JPQL = " ORDER BY listType.name ASC";
075            public static final String ORDER_BY_SQL = " ORDER BY ListType.name ASC";
076            public static final String DATA_SOURCE = "liferayDataSource";
077            public static final String SESSION_FACTORY = "liferaySessionFactory";
078            public static final String TX_MANAGER = "liferayTransactionManager";
079            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ListType"),
081                            true);
082            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ListType"),
084                            true);
085            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.ListType"),
087                            true);
088            public static final long NAME_COLUMN_BITMASK = 1L;
089            public static final long TYPE_COLUMN_BITMASK = 2L;
090    
091            /**
092             * Converts the soap model instance into a normal model instance.
093             *
094             * @param soapModel the soap model instance to convert
095             * @return the normal model instance
096             */
097            public static ListType toModel(ListTypeSoap soapModel) {
098                    if (soapModel == null) {
099                            return null;
100                    }
101    
102                    ListType model = new ListTypeImpl();
103    
104                    model.setMvccVersion(soapModel.getMvccVersion());
105                    model.setListTypeId(soapModel.getListTypeId());
106                    model.setName(soapModel.getName());
107                    model.setType(soapModel.getType());
108    
109                    return model;
110            }
111    
112            /**
113             * Converts the soap model instances into normal model instances.
114             *
115             * @param soapModels the soap model instances to convert
116             * @return the normal model instances
117             */
118            public static List<ListType> toModels(ListTypeSoap[] soapModels) {
119                    if (soapModels == null) {
120                            return null;
121                    }
122    
123                    List<ListType> models = new ArrayList<ListType>(soapModels.length);
124    
125                    for (ListTypeSoap soapModel : soapModels) {
126                            models.add(toModel(soapModel));
127                    }
128    
129                    return models;
130            }
131    
132            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
133                                    "lock.expiration.time.com.liferay.portal.model.ListType"));
134    
135            public ListTypeModelImpl() {
136            }
137    
138            @Override
139            public long getPrimaryKey() {
140                    return _listTypeId;
141            }
142    
143            @Override
144            public void setPrimaryKey(long primaryKey) {
145                    setListTypeId(primaryKey);
146            }
147    
148            @Override
149            public Serializable getPrimaryKeyObj() {
150                    return _listTypeId;
151            }
152    
153            @Override
154            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
155                    setPrimaryKey(((Long)primaryKeyObj).longValue());
156            }
157    
158            @Override
159            public Class<?> getModelClass() {
160                    return ListType.class;
161            }
162    
163            @Override
164            public String getModelClassName() {
165                    return ListType.class.getName();
166            }
167    
168            @Override
169            public Map<String, Object> getModelAttributes() {
170                    Map<String, Object> attributes = new HashMap<String, Object>();
171    
172                    attributes.put("mvccVersion", getMvccVersion());
173                    attributes.put("listTypeId", getListTypeId());
174                    attributes.put("name", getName());
175                    attributes.put("type", getType());
176    
177                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
178                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
179    
180                    return attributes;
181            }
182    
183            @Override
184            public void setModelAttributes(Map<String, Object> attributes) {
185                    Long mvccVersion = (Long)attributes.get("mvccVersion");
186    
187                    if (mvccVersion != null) {
188                            setMvccVersion(mvccVersion);
189                    }
190    
191                    Long listTypeId = (Long)attributes.get("listTypeId");
192    
193                    if (listTypeId != null) {
194                            setListTypeId(listTypeId);
195                    }
196    
197                    String name = (String)attributes.get("name");
198    
199                    if (name != null) {
200                            setName(name);
201                    }
202    
203                    String type = (String)attributes.get("type");
204    
205                    if (type != null) {
206                            setType(type);
207                    }
208            }
209    
210            @JSON
211            @Override
212            public long getMvccVersion() {
213                    return _mvccVersion;
214            }
215    
216            @Override
217            public void setMvccVersion(long mvccVersion) {
218                    _mvccVersion = mvccVersion;
219            }
220    
221            @JSON
222            @Override
223            public long getListTypeId() {
224                    return _listTypeId;
225            }
226    
227            @Override
228            public void setListTypeId(long listTypeId) {
229                    _listTypeId = listTypeId;
230            }
231    
232            @JSON
233            @Override
234            public String getName() {
235                    if (_name == null) {
236                            return StringPool.BLANK;
237                    }
238                    else {
239                            return _name;
240                    }
241            }
242    
243            @Override
244            public void setName(String name) {
245                    _columnBitmask = -1L;
246    
247                    if (_originalName == null) {
248                            _originalName = _name;
249                    }
250    
251                    _name = name;
252            }
253    
254            public String getOriginalName() {
255                    return GetterUtil.getString(_originalName);
256            }
257    
258            @JSON
259            @Override
260            public String getType() {
261                    if (_type == null) {
262                            return StringPool.BLANK;
263                    }
264                    else {
265                            return _type;
266                    }
267            }
268    
269            @Override
270            public void setType(String type) {
271                    _columnBitmask |= TYPE_COLUMN_BITMASK;
272    
273                    if (_originalType == null) {
274                            _originalType = _type;
275                    }
276    
277                    _type = type;
278            }
279    
280            public String getOriginalType() {
281                    return GetterUtil.getString(_originalType);
282            }
283    
284            public long getColumnBitmask() {
285                    return _columnBitmask;
286            }
287    
288            @Override
289            public ExpandoBridge getExpandoBridge() {
290                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
291                            ListType.class.getName(), getPrimaryKey());
292            }
293    
294            @Override
295            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
296                    ExpandoBridge expandoBridge = getExpandoBridge();
297    
298                    expandoBridge.setAttributes(serviceContext);
299            }
300    
301            @Override
302            public ListType toEscapedModel() {
303                    if (_escapedModel == null) {
304                            _escapedModel = (ListType)ProxyUtil.newProxyInstance(_classLoader,
305                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
306                    }
307    
308                    return _escapedModel;
309            }
310    
311            @Override
312            public Object clone() {
313                    ListTypeImpl listTypeImpl = new ListTypeImpl();
314    
315                    listTypeImpl.setMvccVersion(getMvccVersion());
316                    listTypeImpl.setListTypeId(getListTypeId());
317                    listTypeImpl.setName(getName());
318                    listTypeImpl.setType(getType());
319    
320                    listTypeImpl.resetOriginalValues();
321    
322                    return listTypeImpl;
323            }
324    
325            @Override
326            public int compareTo(ListType listType) {
327                    int value = 0;
328    
329                    value = getName().compareToIgnoreCase(listType.getName());
330    
331                    if (value != 0) {
332                            return value;
333                    }
334    
335                    return 0;
336            }
337    
338            @Override
339            public boolean equals(Object obj) {
340                    if (this == obj) {
341                            return true;
342                    }
343    
344                    if (!(obj instanceof ListType)) {
345                            return false;
346                    }
347    
348                    ListType listType = (ListType)obj;
349    
350                    long primaryKey = listType.getPrimaryKey();
351    
352                    if (getPrimaryKey() == primaryKey) {
353                            return true;
354                    }
355                    else {
356                            return false;
357                    }
358            }
359    
360            @Override
361            public int hashCode() {
362                    return (int)getPrimaryKey();
363            }
364    
365            @Override
366            public boolean isEntityCacheEnabled() {
367                    return ENTITY_CACHE_ENABLED;
368            }
369    
370            @Override
371            public boolean isFinderCacheEnabled() {
372                    return FINDER_CACHE_ENABLED;
373            }
374    
375            @Override
376            public void resetOriginalValues() {
377                    ListTypeModelImpl listTypeModelImpl = this;
378    
379                    listTypeModelImpl._originalName = listTypeModelImpl._name;
380    
381                    listTypeModelImpl._originalType = listTypeModelImpl._type;
382    
383                    listTypeModelImpl._columnBitmask = 0;
384            }
385    
386            @Override
387            public CacheModel<ListType> toCacheModel() {
388                    ListTypeCacheModel listTypeCacheModel = new ListTypeCacheModel();
389    
390                    listTypeCacheModel.mvccVersion = getMvccVersion();
391    
392                    listTypeCacheModel.listTypeId = getListTypeId();
393    
394                    listTypeCacheModel.name = getName();
395    
396                    String name = listTypeCacheModel.name;
397    
398                    if ((name != null) && (name.length() == 0)) {
399                            listTypeCacheModel.name = null;
400                    }
401    
402                    listTypeCacheModel.type = getType();
403    
404                    String type = listTypeCacheModel.type;
405    
406                    if ((type != null) && (type.length() == 0)) {
407                            listTypeCacheModel.type = null;
408                    }
409    
410                    return listTypeCacheModel;
411            }
412    
413            @Override
414            public String toString() {
415                    StringBundler sb = new StringBundler(9);
416    
417                    sb.append("{mvccVersion=");
418                    sb.append(getMvccVersion());
419                    sb.append(", listTypeId=");
420                    sb.append(getListTypeId());
421                    sb.append(", name=");
422                    sb.append(getName());
423                    sb.append(", type=");
424                    sb.append(getType());
425                    sb.append("}");
426    
427                    return sb.toString();
428            }
429    
430            @Override
431            public String toXmlString() {
432                    StringBundler sb = new StringBundler(16);
433    
434                    sb.append("<model><model-name>");
435                    sb.append("com.liferay.portal.model.ListType");
436                    sb.append("</model-name>");
437    
438                    sb.append(
439                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
440                    sb.append(getMvccVersion());
441                    sb.append("]]></column-value></column>");
442                    sb.append(
443                            "<column><column-name>listTypeId</column-name><column-value><![CDATA[");
444                    sb.append(getListTypeId());
445                    sb.append("]]></column-value></column>");
446                    sb.append(
447                            "<column><column-name>name</column-name><column-value><![CDATA[");
448                    sb.append(getName());
449                    sb.append("]]></column-value></column>");
450                    sb.append(
451                            "<column><column-name>type</column-name><column-value><![CDATA[");
452                    sb.append(getType());
453                    sb.append("]]></column-value></column>");
454    
455                    sb.append("</model>");
456    
457                    return sb.toString();
458            }
459    
460            private static final ClassLoader _classLoader = ListType.class.getClassLoader();
461            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
462                            ListType.class
463                    };
464            private long _mvccVersion;
465            private long _listTypeId;
466            private String _name;
467            private String _originalName;
468            private String _type;
469            private String _originalType;
470            private long _columnBitmask;
471            private ListType _escapedModel;
472    }