1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.ListType;
29  import com.liferay.portal.model.ListTypeSoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.List;
39  
40  /**
41   * <a href="ListTypeModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>ListType</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portal.model.ListType
56   * @see com.liferay.portal.model.ListTypeModel
57   * @see com.liferay.portal.model.impl.ListTypeImpl
58   *
59   */
60  public class ListTypeModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "ListType";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "listTypeId", new Integer(Types.INTEGER) },
64              
65  
66              { "name", new Integer(Types.VARCHAR) },
67              
68  
69              { "type_", new Integer(Types.VARCHAR) }
70          };
71      public static final String TABLE_SQL_CREATE = "create table ListType (listTypeId INTEGER not null primary key,name VARCHAR(75) null,type_ VARCHAR(75) null)";
72      public static final String TABLE_SQL_DROP = "drop table ListType";
73      public static final String DATA_SOURCE = "liferayDataSource";
74      public static final String SESSION_FACTORY = "liferaySessionFactory";
75      public static final String TX_MANAGER = "liferayTransactionManager";
76      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portal.model.ListType"),
78              true);
79  
80      public static ListType toModel(ListTypeSoap soapModel) {
81          ListType model = new ListTypeImpl();
82  
83          model.setListTypeId(soapModel.getListTypeId());
84          model.setName(soapModel.getName());
85          model.setType(soapModel.getType());
86  
87          return model;
88      }
89  
90      public static List<ListType> toModels(ListTypeSoap[] soapModels) {
91          List<ListType> models = new ArrayList<ListType>(soapModels.length);
92  
93          for (ListTypeSoap soapModel : soapModels) {
94              models.add(toModel(soapModel));
95          }
96  
97          return models;
98      }
99  
100     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
101                 "lock.expiration.time.com.liferay.portal.model.ListType"));
102 
103     public ListTypeModelImpl() {
104     }
105 
106     public int getPrimaryKey() {
107         return _listTypeId;
108     }
109 
110     public void setPrimaryKey(int pk) {
111         setListTypeId(pk);
112     }
113 
114     public Serializable getPrimaryKeyObj() {
115         return new Integer(_listTypeId);
116     }
117 
118     public int getListTypeId() {
119         return _listTypeId;
120     }
121 
122     public void setListTypeId(int listTypeId) {
123         if (listTypeId != _listTypeId) {
124             _listTypeId = listTypeId;
125         }
126     }
127 
128     public String getName() {
129         return GetterUtil.getString(_name);
130     }
131 
132     public void setName(String name) {
133         if (((name == null) && (_name != null)) ||
134                 ((name != null) && (_name == null)) ||
135                 ((name != null) && (_name != null) && !name.equals(_name))) {
136             _name = name;
137         }
138     }
139 
140     public String getType() {
141         return GetterUtil.getString(_type);
142     }
143 
144     public void setType(String type) {
145         if (((type == null) && (_type != null)) ||
146                 ((type != null) && (_type == null)) ||
147                 ((type != null) && (_type != null) && !type.equals(_type))) {
148             _type = type;
149         }
150     }
151 
152     public ListType toEscapedModel() {
153         if (isEscapedModel()) {
154             return (ListType)this;
155         }
156         else {
157             ListType model = new ListTypeImpl();
158 
159             model.setNew(isNew());
160             model.setEscapedModel(true);
161 
162             model.setListTypeId(getListTypeId());
163             model.setName(HtmlUtil.escape(getName()));
164             model.setType(HtmlUtil.escape(getType()));
165 
166             model = (ListType)Proxy.newProxyInstance(ListType.class.getClassLoader(),
167                     new Class[] { ListType.class },
168                     new ReadOnlyBeanHandler(model));
169 
170             return model;
171         }
172     }
173 
174     public Object clone() {
175         ListTypeImpl clone = new ListTypeImpl();
176 
177         clone.setListTypeId(getListTypeId());
178         clone.setName(getName());
179         clone.setType(getType());
180 
181         return clone;
182     }
183 
184     public int compareTo(Object obj) {
185         if (obj == null) {
186             return -1;
187         }
188 
189         ListTypeImpl listType = (ListTypeImpl)obj;
190 
191         int value = 0;
192 
193         value = getName().toLowerCase()
194                     .compareTo(listType.getName().toLowerCase());
195 
196         if (value != 0) {
197             return value;
198         }
199 
200         return 0;
201     }
202 
203     public boolean equals(Object obj) {
204         if (obj == null) {
205             return false;
206         }
207 
208         ListTypeImpl listType = null;
209 
210         try {
211             listType = (ListTypeImpl)obj;
212         }
213         catch (ClassCastException cce) {
214             return false;
215         }
216 
217         int pk = listType.getPrimaryKey();
218 
219         if (getPrimaryKey() == pk) {
220             return true;
221         }
222         else {
223             return false;
224         }
225     }
226 
227     public int hashCode() {
228         return getPrimaryKey();
229     }
230 
231     private int _listTypeId;
232     private String _name;
233     private String _type;
234 }