001    /**
002     * Copyright (c) 2000-2010 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.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.ListType;
022    import com.liferay.portal.model.ListTypeModel;
023    import com.liferay.portal.model.ListTypeSoap;
024    
025    import java.io.Serializable;
026    
027    import java.lang.reflect.Proxy;
028    
029    import java.sql.Types;
030    
031    import java.util.ArrayList;
032    import java.util.List;
033    
034    /**
035     * 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.
036     *
037     * <p>
038     * 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}.
039     * </p>
040     *
041     * <p>
042     * 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.
043     * </p>
044     *
045     * @author Brian Wing Shun Chan
046     * @see ListTypeImpl
047     * @see com.liferay.portal.model.ListType
048     * @see com.liferay.portal.model.ListTypeModel
049     * @generated
050     */
051    public class ListTypeModelImpl extends BaseModelImpl<ListType>
052            implements ListTypeModel {
053            public static final String TABLE_NAME = "ListType";
054            public static final Object[][] TABLE_COLUMNS = {
055                            { "listTypeId", new Integer(Types.INTEGER) },
056                            { "name", new Integer(Types.VARCHAR) },
057                            { "type_", new Integer(Types.VARCHAR) }
058                    };
059            public static final String TABLE_SQL_CREATE = "create table ListType (listTypeId INTEGER not null primary key,name VARCHAR(75) null,type_ VARCHAR(75) null)";
060            public static final String TABLE_SQL_DROP = "drop table ListType";
061            public static final String ORDER_BY_JPQL = " ORDER BY listType.name ASC";
062            public static final String ORDER_BY_SQL = " ORDER BY ListType.name ASC";
063            public static final String DATA_SOURCE = "liferayDataSource";
064            public static final String SESSION_FACTORY = "liferaySessionFactory";
065            public static final String TX_MANAGER = "liferayTransactionManager";
066            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
067                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ListType"),
068                            true);
069            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
070                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ListType"),
071                            true);
072    
073            /**
074             * Converts the soap model instance into a normal model instance.
075             *
076             * @param soapModel the soap model instance to convert
077             * @return the normal model instance
078             */
079            public static ListType toModel(ListTypeSoap soapModel) {
080                    ListType model = new ListTypeImpl();
081    
082                    model.setListTypeId(soapModel.getListTypeId());
083                    model.setName(soapModel.getName());
084                    model.setType(soapModel.getType());
085    
086                    return model;
087            }
088    
089            /**
090             * Converts the soap model instances into normal model instances.
091             *
092             * @param soapModels the soap model instances to convert
093             * @return the normal model instances
094             */
095            public static List<ListType> toModels(ListTypeSoap[] soapModels) {
096                    List<ListType> models = new ArrayList<ListType>(soapModels.length);
097    
098                    for (ListTypeSoap soapModel : soapModels) {
099                            models.add(toModel(soapModel));
100                    }
101    
102                    return models;
103            }
104    
105            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
106                                    "lock.expiration.time.com.liferay.portal.model.ListType"));
107    
108            public ListTypeModelImpl() {
109            }
110    
111            public int getPrimaryKey() {
112                    return _listTypeId;
113            }
114    
115            public void setPrimaryKey(int pk) {
116                    setListTypeId(pk);
117            }
118    
119            public Serializable getPrimaryKeyObj() {
120                    return new Integer(_listTypeId);
121            }
122    
123            public int getListTypeId() {
124                    return _listTypeId;
125            }
126    
127            public void setListTypeId(int listTypeId) {
128                    _listTypeId = listTypeId;
129            }
130    
131            public String getName() {
132                    if (_name == null) {
133                            return StringPool.BLANK;
134                    }
135                    else {
136                            return _name;
137                    }
138            }
139    
140            public void setName(String name) {
141                    _name = name;
142            }
143    
144            public String getType() {
145                    if (_type == null) {
146                            return StringPool.BLANK;
147                    }
148                    else {
149                            return _type;
150                    }
151            }
152    
153            public void setType(String type) {
154                    _type = type;
155            }
156    
157            public ListType toEscapedModel() {
158                    if (isEscapedModel()) {
159                            return (ListType)this;
160                    }
161                    else {
162                            return (ListType)Proxy.newProxyInstance(ListType.class.getClassLoader(),
163                                    new Class[] { ListType.class }, new AutoEscapeBeanHandler(this));
164                    }
165            }
166    
167            public Object clone() {
168                    ListTypeImpl clone = new ListTypeImpl();
169    
170                    clone.setListTypeId(getListTypeId());
171                    clone.setName(getName());
172                    clone.setType(getType());
173    
174                    return clone;
175            }
176    
177            public int compareTo(ListType listType) {
178                    int value = 0;
179    
180                    value = getName().toLowerCase()
181                                            .compareTo(listType.getName().toLowerCase());
182    
183                    if (value != 0) {
184                            return value;
185                    }
186    
187                    return 0;
188            }
189    
190            public boolean equals(Object obj) {
191                    if (obj == null) {
192                            return false;
193                    }
194    
195                    ListType listType = null;
196    
197                    try {
198                            listType = (ListType)obj;
199                    }
200                    catch (ClassCastException cce) {
201                            return false;
202                    }
203    
204                    int pk = listType.getPrimaryKey();
205    
206                    if (getPrimaryKey() == pk) {
207                            return true;
208                    }
209                    else {
210                            return false;
211                    }
212            }
213    
214            public int hashCode() {
215                    return getPrimaryKey();
216            }
217    
218            public String toString() {
219                    StringBundler sb = new StringBundler(7);
220    
221                    sb.append("{listTypeId=");
222                    sb.append(getListTypeId());
223                    sb.append(", name=");
224                    sb.append(getName());
225                    sb.append(", type=");
226                    sb.append(getType());
227                    sb.append("}");
228    
229                    return sb.toString();
230            }
231    
232            public String toXmlString() {
233                    StringBundler sb = new StringBundler(13);
234    
235                    sb.append("<model><model-name>");
236                    sb.append("com.liferay.portal.model.ListType");
237                    sb.append("</model-name>");
238    
239                    sb.append(
240                            "<column><column-name>listTypeId</column-name><column-value><![CDATA[");
241                    sb.append(getListTypeId());
242                    sb.append("]]></column-value></column>");
243                    sb.append(
244                            "<column><column-name>name</column-name><column-value><![CDATA[");
245                    sb.append(getName());
246                    sb.append("]]></column-value></column>");
247                    sb.append(
248                            "<column><column-name>type</column-name><column-value><![CDATA[");
249                    sb.append(getType());
250                    sb.append("]]></column-value></column>");
251    
252                    sb.append("</model>");
253    
254                    return sb.toString();
255            }
256    
257            private int _listTypeId;
258            private String _name;
259            private String _type;
260    }