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