1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.ListType;
26  import com.liferay.portal.model.ListTypeSoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="ListTypeModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>ListType</code> table
47   * in the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portal.model.ListType
53   * @see com.liferay.portal.model.ListTypeModel
54   * @see com.liferay.portal.model.impl.ListTypeImpl
55   *
56   */
57  public class ListTypeModelImpl extends BaseModelImpl {
58      public static final String TABLE_NAME = "ListType";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "listTypeId", new Integer(Types.INTEGER) },
61              
62  
63              { "name", new Integer(Types.VARCHAR) },
64              
65  
66              { "type_", new Integer(Types.VARCHAR) }
67          };
68      public static final String TABLE_SQL_CREATE = "create table ListType (listTypeId INTEGER not null primary key,name VARCHAR(75) null,type_ VARCHAR(75) null)";
69      public static final String TABLE_SQL_DROP = "drop table ListType";
70      public static final String DATA_SOURCE = "liferayDataSource";
71      public static final String SESSION_FACTORY = "liferaySessionFactory";
72      public static final String TX_MANAGER = "liferayTransactionManager";
73      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.finder.cache.enabled.com.liferay.portal.model.ListType"),
75              true);
76  
77      public static ListType toModel(ListTypeSoap soapModel) {
78          ListType model = new ListTypeImpl();
79  
80          model.setListTypeId(soapModel.getListTypeId());
81          model.setName(soapModel.getName());
82          model.setType(soapModel.getType());
83  
84          return model;
85      }
86  
87      public static List<ListType> toModels(ListTypeSoap[] soapModels) {
88          List<ListType> models = new ArrayList<ListType>(soapModels.length);
89  
90          for (ListTypeSoap soapModel : soapModels) {
91              models.add(toModel(soapModel));
92          }
93  
94          return models;
95      }
96  
97      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
98                  "lock.expiration.time.com.liferay.portal.model.ListType"));
99  
100     public ListTypeModelImpl() {
101     }
102 
103     public int getPrimaryKey() {
104         return _listTypeId;
105     }
106 
107     public void setPrimaryKey(int pk) {
108         setListTypeId(pk);
109     }
110 
111     public Serializable getPrimaryKeyObj() {
112         return new Integer(_listTypeId);
113     }
114 
115     public int getListTypeId() {
116         return _listTypeId;
117     }
118 
119     public void setListTypeId(int listTypeId) {
120         if (listTypeId != _listTypeId) {
121             _listTypeId = listTypeId;
122         }
123     }
124 
125     public String getName() {
126         return GetterUtil.getString(_name);
127     }
128 
129     public void setName(String name) {
130         if (((name == null) && (_name != null)) ||
131                 ((name != null) && (_name == null)) ||
132                 ((name != null) && (_name != null) && !name.equals(_name))) {
133             _name = name;
134         }
135     }
136 
137     public String getType() {
138         return GetterUtil.getString(_type);
139     }
140 
141     public void setType(String type) {
142         if (((type == null) && (_type != null)) ||
143                 ((type != null) && (_type == null)) ||
144                 ((type != null) && (_type != null) && !type.equals(_type))) {
145             _type = type;
146         }
147     }
148 
149     public ListType toEscapedModel() {
150         if (isEscapedModel()) {
151             return (ListType)this;
152         }
153         else {
154             ListType model = new ListTypeImpl();
155 
156             model.setNew(isNew());
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 }