1   /**
2    * Copyright (c) 2000-2008 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  import com.liferay.portal.util.PropsUtil;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="ListTypeModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>ListType</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.ListType
57   * @see com.liferay.portal.service.model.ListTypeModel
58   * @see com.liferay.portal.service.model.impl.ListTypeImpl
59   *
60   */
61  public class ListTypeModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "ListType";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "listTypeId", new Integer(Types.INTEGER) },
65              
66  
67              { "name", new Integer(Types.VARCHAR) },
68              
69  
70              { "type_", new Integer(Types.VARCHAR) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table ListType (listTypeId INTEGER not null primary key,name VARCHAR(75) null,type_ VARCHAR(75) null)";
73      public static final String TABLE_SQL_DROP = "drop table ListType";
74      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
75                  "value.object.finder.cache.enabled.com.liferay.portal.model.ListType"),
76              true);
77  
78      public static ListType toModel(ListTypeSoap soapModel) {
79          ListType model = new ListTypeImpl();
80  
81          model.setListTypeId(soapModel.getListTypeId());
82          model.setName(soapModel.getName());
83          model.setType(soapModel.getType());
84  
85          return model;
86      }
87  
88      public static List<ListType> toModels(ListTypeSoap[] soapModels) {
89          List<ListType> models = new ArrayList<ListType>(soapModels.length);
90  
91          for (ListTypeSoap soapModel : soapModels) {
92              models.add(toModel(soapModel));
93          }
94  
95          return models;
96      }
97  
98      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
99                  "lock.expiration.time.com.liferay.portal.model.ListType"));
100 
101     public ListTypeModelImpl() {
102     }
103 
104     public int getPrimaryKey() {
105         return _listTypeId;
106     }
107 
108     public void setPrimaryKey(int pk) {
109         setListTypeId(pk);
110     }
111 
112     public Serializable getPrimaryKeyObj() {
113         return new Integer(_listTypeId);
114     }
115 
116     public int getListTypeId() {
117         return _listTypeId;
118     }
119 
120     public void setListTypeId(int listTypeId) {
121         if (listTypeId != _listTypeId) {
122             _listTypeId = listTypeId;
123         }
124     }
125 
126     public String getName() {
127         return GetterUtil.getString(_name);
128     }
129 
130     public void setName(String name) {
131         if (((name == null) && (_name != null)) ||
132                 ((name != null) && (_name == null)) ||
133                 ((name != null) && (_name != null) && !name.equals(_name))) {
134             _name = name;
135         }
136     }
137 
138     public String getType() {
139         return GetterUtil.getString(_type);
140     }
141 
142     public void setType(String type) {
143         if (((type == null) && (_type != null)) ||
144                 ((type != null) && (_type == null)) ||
145                 ((type != null) && (_type != null) && !type.equals(_type))) {
146             _type = type;
147         }
148     }
149 
150     public ListType toEscapedModel() {
151         if (isEscapedModel()) {
152             return (ListType)this;
153         }
154         else {
155             ListType model = new ListTypeImpl();
156 
157             model.setEscapedModel(true);
158 
159             model.setListTypeId(getListTypeId());
160             model.setName(HtmlUtil.escape(getName()));
161             model.setType(HtmlUtil.escape(getType()));
162 
163             model = (ListType)Proxy.newProxyInstance(ListType.class.getClassLoader(),
164                     new Class[] { ListType.class },
165                     new ReadOnlyBeanHandler(model));
166 
167             return model;
168         }
169     }
170 
171     public Object clone() {
172         ListTypeImpl clone = new ListTypeImpl();
173 
174         clone.setListTypeId(getListTypeId());
175         clone.setName(getName());
176         clone.setType(getType());
177 
178         return clone;
179     }
180 
181     public int compareTo(Object obj) {
182         if (obj == null) {
183             return -1;
184         }
185 
186         ListTypeImpl listType = (ListTypeImpl)obj;
187 
188         int value = 0;
189 
190         value = getName().toLowerCase()
191                     .compareTo(listType.getName().toLowerCase());
192 
193         if (value != 0) {
194             return value;
195         }
196 
197         return 0;
198     }
199 
200     public boolean equals(Object obj) {
201         if (obj == null) {
202             return false;
203         }
204 
205         ListTypeImpl listType = null;
206 
207         try {
208             listType = (ListTypeImpl)obj;
209         }
210         catch (ClassCastException cce) {
211             return false;
212         }
213 
214         int pk = listType.getPrimaryKey();
215 
216         if (getPrimaryKey() == pk) {
217             return true;
218         }
219         else {
220             return false;
221         }
222     }
223 
224     public int hashCode() {
225         return getPrimaryKey();
226     }
227 
228     private int _listTypeId;
229     private String _name;
230     private String _type;
231 }