001    /**
002     * Copyright (c) 2000-2013 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 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    /**
038     * 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.
039     *
040     * <p>
041     * 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}.
042     * </p>
043     *
044     * @author Brian Wing Shun Chan
045     * @see ListTypeImpl
046     * @see com.liferay.portal.model.ListType
047     * @see com.liferay.portal.model.ListTypeModel
048     * @generated
049     */
050    @JSON(strict = true)
051    public class ListTypeModelImpl extends BaseModelImpl<ListType>
052            implements ListTypeModel {
053            /*
054             * NOTE FOR DEVELOPERS:
055             *
056             * 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.
057             */
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    
082            /**
083             * Converts the soap model instance into a normal model instance.
084             *
085             * @param soapModel the soap model instance to convert
086             * @return the normal model instance
087             */
088            public static ListType toModel(ListTypeSoap soapModel) {
089                    if (soapModel == null) {
090                            return null;
091                    }
092    
093                    ListType model = new ListTypeImpl();
094    
095                    model.setListTypeId(soapModel.getListTypeId());
096                    model.setName(soapModel.getName());
097                    model.setType(soapModel.getType());
098    
099                    return model;
100            }
101    
102            /**
103             * Converts the soap model instances into normal model instances.
104             *
105             * @param soapModels the soap model instances to convert
106             * @return the normal model instances
107             */
108            public static List<ListType> toModels(ListTypeSoap[] soapModels) {
109                    if (soapModels == null) {
110                            return null;
111                    }
112    
113                    List<ListType> models = new ArrayList<ListType>(soapModels.length);
114    
115                    for (ListTypeSoap soapModel : soapModels) {
116                            models.add(toModel(soapModel));
117                    }
118    
119                    return models;
120            }
121    
122            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
123                                    "lock.expiration.time.com.liferay.portal.model.ListType"));
124    
125            public ListTypeModelImpl() {
126            }
127    
128            public int getPrimaryKey() {
129                    return _listTypeId;
130            }
131    
132            public void setPrimaryKey(int primaryKey) {
133                    setListTypeId(primaryKey);
134            }
135    
136            public Serializable getPrimaryKeyObj() {
137                    return new Integer(_listTypeId);
138            }
139    
140            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
141                    setPrimaryKey(((Integer)primaryKeyObj).intValue());
142            }
143    
144            public Class<?> getModelClass() {
145                    return ListType.class;
146            }
147    
148            public String getModelClassName() {
149                    return ListType.class.getName();
150            }
151    
152            @Override
153            public Map<String, Object> getModelAttributes() {
154                    Map<String, Object> attributes = new HashMap<String, Object>();
155    
156                    attributes.put("listTypeId", getListTypeId());
157                    attributes.put("name", getName());
158                    attributes.put("type", getType());
159    
160                    return attributes;
161            }
162    
163            @Override
164            public void setModelAttributes(Map<String, Object> attributes) {
165                    Integer listTypeId = (Integer)attributes.get("listTypeId");
166    
167                    if (listTypeId != null) {
168                            setListTypeId(listTypeId);
169                    }
170    
171                    String name = (String)attributes.get("name");
172    
173                    if (name != null) {
174                            setName(name);
175                    }
176    
177                    String type = (String)attributes.get("type");
178    
179                    if (type != null) {
180                            setType(type);
181                    }
182            }
183    
184            @JSON
185            public int getListTypeId() {
186                    return _listTypeId;
187            }
188    
189            public void setListTypeId(int listTypeId) {
190                    _listTypeId = listTypeId;
191            }
192    
193            @JSON
194            public String getName() {
195                    if (_name == null) {
196                            return StringPool.BLANK;
197                    }
198                    else {
199                            return _name;
200                    }
201            }
202    
203            public void setName(String name) {
204                    _columnBitmask = -1L;
205    
206                    _name = name;
207            }
208    
209            @JSON
210            public String getType() {
211                    if (_type == null) {
212                            return StringPool.BLANK;
213                    }
214                    else {
215                            return _type;
216                    }
217            }
218    
219            public void setType(String type) {
220                    _columnBitmask |= TYPE_COLUMN_BITMASK;
221    
222                    if (_originalType == null) {
223                            _originalType = _type;
224                    }
225    
226                    _type = type;
227            }
228    
229            public String getOriginalType() {
230                    return GetterUtil.getString(_originalType);
231            }
232    
233            public long getColumnBitmask() {
234                    return _columnBitmask;
235            }
236    
237            @Override
238            public ListType toEscapedModel() {
239                    if (_escapedModel == null) {
240                            _escapedModel = (ListType)ProxyUtil.newProxyInstance(_classLoader,
241                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
242                    }
243    
244                    return _escapedModel;
245            }
246    
247            public ListType toUnescapedModel() {
248                    return (ListType)this;
249            }
250    
251            @Override
252            public Object clone() {
253                    ListTypeImpl listTypeImpl = new ListTypeImpl();
254    
255                    listTypeImpl.setListTypeId(getListTypeId());
256                    listTypeImpl.setName(getName());
257                    listTypeImpl.setType(getType());
258    
259                    listTypeImpl.resetOriginalValues();
260    
261                    return listTypeImpl;
262            }
263    
264            public int compareTo(ListType listType) {
265                    int value = 0;
266    
267                    value = getName().toLowerCase()
268                                            .compareTo(listType.getName().toLowerCase());
269    
270                    if (value != 0) {
271                            return value;
272                    }
273    
274                    return 0;
275            }
276    
277            @Override
278            public boolean equals(Object obj) {
279                    if (this == obj) {
280                            return true;
281                    }
282    
283                    if (!(obj instanceof ListType)) {
284                            return false;
285                    }
286    
287                    ListType listType = (ListType)obj;
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    }