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