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.portlet.messageboards.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.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.portlet.messageboards.model.MBMessageFlag;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="MBMessageFlagModelImpl.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>MBMessageFlag</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portlet.messageboards.service.model.MBMessageFlag
54   * @see com.liferay.portlet.messageboards.service.model.MBMessageFlagModel
55   * @see com.liferay.portlet.messageboards.service.model.impl.MBMessageFlagImpl
56   *
57   */
58  public class MBMessageFlagModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "MBMessageFlag";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "messageFlagId", new Integer(Types.BIGINT) },
62              
63  
64              { "userId", new Integer(Types.BIGINT) },
65              
66  
67              { "messageId", new Integer(Types.BIGINT) },
68              
69  
70              { "flag", new Integer(Types.INTEGER) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table MBMessageFlag (messageFlagId LONG not null primary key,userId LONG,messageId LONG,flag INTEGER)";
73      public static final String TABLE_SQL_DROP = "drop table MBMessageFlag";
74      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
75                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBMessageFlag"),
76              true);
77      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
78                  "lock.expiration.time.com.liferay.portlet.messageboards.model.MBMessageFlag"));
79  
80      public MBMessageFlagModelImpl() {
81      }
82  
83      public long getPrimaryKey() {
84          return _messageFlagId;
85      }
86  
87      public void setPrimaryKey(long pk) {
88          setMessageFlagId(pk);
89      }
90  
91      public Serializable getPrimaryKeyObj() {
92          return new Long(_messageFlagId);
93      }
94  
95      public long getMessageFlagId() {
96          return _messageFlagId;
97      }
98  
99      public void setMessageFlagId(long messageFlagId) {
100         if (messageFlagId != _messageFlagId) {
101             _messageFlagId = messageFlagId;
102         }
103     }
104 
105     public long getUserId() {
106         return _userId;
107     }
108 
109     public void setUserId(long userId) {
110         if (userId != _userId) {
111             _userId = userId;
112         }
113     }
114 
115     public long getMessageId() {
116         return _messageId;
117     }
118 
119     public void setMessageId(long messageId) {
120         if (messageId != _messageId) {
121             _messageId = messageId;
122         }
123     }
124 
125     public int getFlag() {
126         return _flag;
127     }
128 
129     public void setFlag(int flag) {
130         if (flag != _flag) {
131             _flag = flag;
132         }
133     }
134 
135     public MBMessageFlag toEscapedModel() {
136         if (isEscapedModel()) {
137             return (MBMessageFlag)this;
138         }
139         else {
140             MBMessageFlag model = new MBMessageFlagImpl();
141 
142             model.setEscapedModel(true);
143 
144             model.setMessageFlagId(getMessageFlagId());
145             model.setUserId(getUserId());
146             model.setMessageId(getMessageId());
147             model.setFlag(getFlag());
148 
149             model = (MBMessageFlag)Proxy.newProxyInstance(MBMessageFlag.class.getClassLoader(),
150                     new Class[] { MBMessageFlag.class },
151                     new ReadOnlyBeanHandler(model));
152 
153             return model;
154         }
155     }
156 
157     public Object clone() {
158         MBMessageFlagImpl clone = new MBMessageFlagImpl();
159 
160         clone.setMessageFlagId(getMessageFlagId());
161         clone.setUserId(getUserId());
162         clone.setMessageId(getMessageId());
163         clone.setFlag(getFlag());
164 
165         return clone;
166     }
167 
168     public int compareTo(Object obj) {
169         if (obj == null) {
170             return -1;
171         }
172 
173         MBMessageFlagImpl mbMessageFlag = (MBMessageFlagImpl)obj;
174 
175         long pk = mbMessageFlag.getPrimaryKey();
176 
177         if (getPrimaryKey() < pk) {
178             return -1;
179         }
180         else if (getPrimaryKey() > pk) {
181             return 1;
182         }
183         else {
184             return 0;
185         }
186     }
187 
188     public boolean equals(Object obj) {
189         if (obj == null) {
190             return false;
191         }
192 
193         MBMessageFlagImpl mbMessageFlag = null;
194 
195         try {
196             mbMessageFlag = (MBMessageFlagImpl)obj;
197         }
198         catch (ClassCastException cce) {
199             return false;
200         }
201 
202         long pk = mbMessageFlag.getPrimaryKey();
203 
204         if (getPrimaryKey() == pk) {
205             return true;
206         }
207         else {
208             return false;
209         }
210     }
211 
212     public int hashCode() {
213         return (int)getPrimaryKey();
214     }
215 
216     private long _messageFlagId;
217     private long _userId;
218     private long _messageId;
219     private int _flag;
220 }