001    /**
002     * Copyright (c) 2000-2012 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.List;
034    
035    /**
036     * 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.
037     *
038     * <p>
039     * 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}.
040     * </p>
041     *
042     * @author Brian Wing Shun Chan
043     * @see ListTypeImpl
044     * @see com.liferay.portal.model.ListType
045     * @see com.liferay.portal.model.ListTypeModel
046     * @generated
047     */
048    @JSON(strict = true)
049    public class ListTypeModelImpl extends BaseModelImpl<ListType>
050            implements ListTypeModel {
051            /*
052             * NOTE FOR DEVELOPERS:
053             *
054             * 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.
055             */
056            public static final String TABLE_NAME = "ListType";
057            public static final Object[][] TABLE_COLUMNS = {
058                            { "listTypeId", Types.INTEGER },
059                            { "name", Types.VARCHAR },
060                            { "type_", Types.VARCHAR }
061                    };
062            public static final String TABLE_SQL_CREATE = "create table ListType (listTypeId INTEGER not null primary key,name VARCHAR(75) null,type_ VARCHAR(75) null)";
063            public static final String TABLE_SQL_DROP = "drop table ListType";
064            public static final String ORDER_BY_JPQL = " ORDER BY listType.name ASC";
065            public static final String ORDER_BY_SQL = " ORDER BY ListType.name ASC";
066            public static final String DATA_SOURCE = "liferayDataSource";
067            public static final String SESSION_FACTORY = "liferaySessionFactory";
068            public static final String TX_MANAGER = "liferayTransactionManager";
069            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
070                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ListType"),
071                            true);
072            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ListType"),
074                            true);
075            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.ListType"),
077                            true);
078            public static long TYPE_COLUMN_BITMASK = 1L;
079    
080            /**
081             * Converts the soap model instance into a normal model instance.
082             *
083             * @param soapModel the soap model instance to convert
084             * @return the normal model instance
085             */
086            public static ListType toModel(ListTypeSoap soapModel) {
087                    ListType model = new ListTypeImpl();
088    
089                    model.setListTypeId(soapModel.getListTypeId());
090                    model.setName(soapModel.getName());
091                    model.setType(soapModel.getType());
092    
093                    return model;
094            }
095    
096            /**
097             * Converts the soap model instances into normal model instances.
098             *
099             * @param soapModels the soap model instances to convert
100             * @return the normal model instances
101             */
102            public static List<ListType> toModels(ListTypeSoap[] soapModels) {
103                    List<ListType> models = new ArrayList<ListType>(soapModels.length);
104    
105                    for (ListTypeSoap soapModel : soapModels) {
106                            models.add(toModel(soapModel));
107                    }
108    
109                    return models;
110            }
111    
112            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
113                                    "lock.expiration.time.com.liferay.portal.model.ListType"));
114    
115            public ListTypeModelImpl() {
116            }
117    
118            public int getPrimaryKey() {
119                    return _listTypeId;
120            }
121    
122            public void setPrimaryKey(int primaryKey) {
123                    setListTypeId(primaryKey);
124            }
125    
126            public Serializable getPrimaryKeyObj() {
127                    return new Integer(_listTypeId);
128            }
129    
130            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
131                    setPrimaryKey(((Integer)primaryKeyObj).intValue());
132            }
133    
134            public Class<?> getModelClass() {
135                    return ListType.class;
136            }
137    
138            public String getModelClassName() {
139                    return ListType.class.getName();
140            }
141    
142            @JSON
143            public int getListTypeId() {
144                    return _listTypeId;
145            }
146    
147            public void setListTypeId(int listTypeId) {
148                    _listTypeId = listTypeId;
149            }
150    
151            @JSON
152            public String getName() {
153                    if (_name == null) {
154                            return StringPool.BLANK;
155                    }
156                    else {
157                            return _name;
158                    }
159            }
160    
161            public void setName(String name) {
162                    _columnBitmask = -1L;
163    
164                    _name = name;
165            }
166    
167            @JSON
168            public String getType() {
169                    if (_type == null) {
170                            return StringPool.BLANK;
171                    }
172                    else {
173                            return _type;
174                    }
175            }
176    
177            public void setType(String type) {
178                    _columnBitmask |= TYPE_COLUMN_BITMASK;
179    
180                    if (_originalType == null) {
181                            _originalType = _type;
182                    }
183    
184                    _type = type;
185            }
186    
187            public String getOriginalType() {
188                    return GetterUtil.getString(_originalType);
189            }
190    
191            public long getColumnBitmask() {
192                    return _columnBitmask;
193            }
194    
195            @Override
196            public ListType toEscapedModel() {
197                    if (_escapedModelProxy == null) {
198                            _escapedModelProxy = (ListType)ProxyUtil.newProxyInstance(_classLoader,
199                                            _escapedModelProxyInterfaces,
200                                            new AutoEscapeBeanHandler(this));
201                    }
202    
203                    return _escapedModelProxy;
204            }
205    
206            @Override
207            public Object clone() {
208                    ListTypeImpl listTypeImpl = new ListTypeImpl();
209    
210                    listTypeImpl.setListTypeId(getListTypeId());
211                    listTypeImpl.setName(getName());
212                    listTypeImpl.setType(getType());
213    
214                    listTypeImpl.resetOriginalValues();
215    
216                    return listTypeImpl;
217            }
218    
219            public int compareTo(ListType listType) {
220                    int value = 0;
221    
222                    value = getName().toLowerCase()
223                                            .compareTo(listType.getName().toLowerCase());
224    
225                    if (value != 0) {
226                            return value;
227                    }
228    
229                    return 0;
230            }
231    
232            @Override
233            public boolean equals(Object obj) {
234                    if (obj == null) {
235                            return false;
236                    }
237    
238                    ListType listType = null;
239    
240                    try {
241                            listType = (ListType)obj;
242                    }
243                    catch (ClassCastException cce) {
244                            return false;
245                    }
246    
247                    int primaryKey = listType.getPrimaryKey();
248    
249                    if (getPrimaryKey() == primaryKey) {
250                            return true;
251                    }
252                    else {
253                            return false;
254                    }
255            }
256    
257            @Override
258            public int hashCode() {
259                    return getPrimaryKey();
260            }
261    
262            @Override
263            public void resetOriginalValues() {
264                    ListTypeModelImpl listTypeModelImpl = this;
265    
266                    listTypeModelImpl._originalType = listTypeModelImpl._type;
267    
268                    listTypeModelImpl._columnBitmask = 0;
269            }
270    
271            @Override
272            public CacheModel<ListType> toCacheModel() {
273                    ListTypeCacheModel listTypeCacheModel = new ListTypeCacheModel();
274    
275                    listTypeCacheModel.listTypeId = getListTypeId();
276    
277                    listTypeCacheModel.name = getName();
278    
279                    String name = listTypeCacheModel.name;
280    
281                    if ((name != null) && (name.length() == 0)) {
282                            listTypeCacheModel.name = null;
283                    }
284    
285                    listTypeCacheModel.type = getType();
286    
287                    String type = listTypeCacheModel.type;
288    
289                    if ((type != null) && (type.length() == 0)) {
290                            listTypeCacheModel.type = null;
291                    }
292    
293                    return listTypeCacheModel;
294            }
295    
296            @Override
297            public String toString() {
298                    StringBundler sb = new StringBundler(7);
299    
300                    sb.append("{listTypeId=");
301                    sb.append(getListTypeId());
302                    sb.append(", name=");
303                    sb.append(getName());
304                    sb.append(", type=");
305                    sb.append(getType());
306                    sb.append("}");
307    
308                    return sb.toString();
309            }
310    
311            public String toXmlString() {
312                    StringBundler sb = new StringBundler(13);
313    
314                    sb.append("<model><model-name>");
315                    sb.append("com.liferay.portal.model.ListType");
316                    sb.append("</model-name>");
317    
318                    sb.append(
319                            "<column><column-name>listTypeId</column-name><column-value><![CDATA[");
320                    sb.append(getListTypeId());
321                    sb.append("]]></column-value></column>");
322                    sb.append(
323                            "<column><column-name>name</column-name><column-value><![CDATA[");
324                    sb.append(getName());
325                    sb.append("]]></column-value></column>");
326                    sb.append(
327                            "<column><column-name>type</column-name><column-value><![CDATA[");
328                    sb.append(getType());
329                    sb.append("]]></column-value></column>");
330    
331                    sb.append("</model>");
332    
333                    return sb.toString();
334            }
335    
336            private static ClassLoader _classLoader = ListType.class.getClassLoader();
337            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
338                            ListType.class
339                    };
340            private int _listTypeId;
341            private String _name;
342            private String _type;
343            private String _originalType;
344            private long _columnBitmask;
345            private ListType _escapedModelProxy;
346    }