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