001    /**
002     * Copyright (c) 2000-2011 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                    _name = name;
163            }
164    
165            @JSON
166            public String getType() {
167                    if (_type == null) {
168                            return StringPool.BLANK;
169                    }
170                    else {
171                            return _type;
172                    }
173            }
174    
175            public void setType(String type) {
176                    _columnBitmask |= TYPE_COLUMN_BITMASK;
177    
178                    if (_originalType == null) {
179                            _originalType = _type;
180                    }
181    
182                    _type = type;
183            }
184    
185            public String getOriginalType() {
186                    return GetterUtil.getString(_originalType);
187            }
188    
189            public long getColumnBitmask() {
190                    return _columnBitmask;
191            }
192    
193            @Override
194            public ListType toEscapedModel() {
195                    if (_escapedModelProxy == null) {
196                            _escapedModelProxy = (ListType)ProxyUtil.newProxyInstance(_classLoader,
197                                            _escapedModelProxyInterfaces,
198                                            new AutoEscapeBeanHandler(this));
199                    }
200    
201                    return _escapedModelProxy;
202            }
203    
204            @Override
205            public Object clone() {
206                    ListTypeImpl listTypeImpl = new ListTypeImpl();
207    
208                    listTypeImpl.setListTypeId(getListTypeId());
209                    listTypeImpl.setName(getName());
210                    listTypeImpl.setType(getType());
211    
212                    listTypeImpl.resetOriginalValues();
213    
214                    return listTypeImpl;
215            }
216    
217            public int compareTo(ListType listType) {
218                    int value = 0;
219    
220                    value = getName().toLowerCase()
221                                            .compareTo(listType.getName().toLowerCase());
222    
223                    if (value != 0) {
224                            return value;
225                    }
226    
227                    return 0;
228            }
229    
230            @Override
231            public boolean equals(Object obj) {
232                    if (obj == null) {
233                            return false;
234                    }
235    
236                    ListType listType = null;
237    
238                    try {
239                            listType = (ListType)obj;
240                    }
241                    catch (ClassCastException cce) {
242                            return false;
243                    }
244    
245                    int primaryKey = listType.getPrimaryKey();
246    
247                    if (getPrimaryKey() == primaryKey) {
248                            return true;
249                    }
250                    else {
251                            return false;
252                    }
253            }
254    
255            @Override
256            public int hashCode() {
257                    return getPrimaryKey();
258            }
259    
260            @Override
261            public void resetOriginalValues() {
262                    ListTypeModelImpl listTypeModelImpl = this;
263    
264                    listTypeModelImpl._originalType = listTypeModelImpl._type;
265    
266                    listTypeModelImpl._columnBitmask = 0;
267            }
268    
269            @Override
270            public CacheModel<ListType> toCacheModel() {
271                    ListTypeCacheModel listTypeCacheModel = new ListTypeCacheModel();
272    
273                    listTypeCacheModel.listTypeId = getListTypeId();
274    
275                    listTypeCacheModel.name = getName();
276    
277                    String name = listTypeCacheModel.name;
278    
279                    if ((name != null) && (name.length() == 0)) {
280                            listTypeCacheModel.name = null;
281                    }
282    
283                    listTypeCacheModel.type = getType();
284    
285                    String type = listTypeCacheModel.type;
286    
287                    if ((type != null) && (type.length() == 0)) {
288                            listTypeCacheModel.type = null;
289                    }
290    
291                    return listTypeCacheModel;
292            }
293    
294            @Override
295            public String toString() {
296                    StringBundler sb = new StringBundler(7);
297    
298                    sb.append("{listTypeId=");
299                    sb.append(getListTypeId());
300                    sb.append(", name=");
301                    sb.append(getName());
302                    sb.append(", type=");
303                    sb.append(getType());
304                    sb.append("}");
305    
306                    return sb.toString();
307            }
308    
309            public String toXmlString() {
310                    StringBundler sb = new StringBundler(13);
311    
312                    sb.append("<model><model-name>");
313                    sb.append("com.liferay.portal.model.ListType");
314                    sb.append("</model-name>");
315    
316                    sb.append(
317                            "<column><column-name>listTypeId</column-name><column-value><![CDATA[");
318                    sb.append(getListTypeId());
319                    sb.append("]]></column-value></column>");
320                    sb.append(
321                            "<column><column-name>name</column-name><column-value><![CDATA[");
322                    sb.append(getName());
323                    sb.append("]]></column-value></column>");
324                    sb.append(
325                            "<column><column-name>type</column-name><column-value><![CDATA[");
326                    sb.append(getType());
327                    sb.append("]]></column-value></column>");
328    
329                    sb.append("</model>");
330    
331                    return sb.toString();
332            }
333    
334            private static ClassLoader _classLoader = ListType.class.getClassLoader();
335            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
336                            ListType.class
337                    };
338            private int _listTypeId;
339            private String _name;
340            private String _type;
341            private String _originalType;
342            private long _columnBitmask;
343            private ListType _escapedModelProxy;
344    }