1
22
23 package com.liferay.portlet.polls.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.polls.model.PollsChoice;
31
32 import com.liferay.util.Html;
33
34 import java.io.Serializable;
35
36 import java.lang.reflect.Proxy;
37
38 import java.sql.Types;
39
40
60 public class PollsChoiceModelImpl extends BaseModelImpl {
61 public static final String TABLE_NAME = "PollsChoice";
62 public static final Object[][] TABLE_COLUMNS = {
63 { "uuid_", new Integer(Types.VARCHAR) },
64
65
66 { "choiceId", new Integer(Types.BIGINT) },
67
68
69 { "questionId", new Integer(Types.BIGINT) },
70
71
72 { "name", new Integer(Types.VARCHAR) },
73
74
75 { "description", new Integer(Types.VARCHAR) }
76 };
77 public static final String TABLE_SQL_CREATE = "create table PollsChoice (uuid_ VARCHAR(75) null,choiceId LONG not null primary key,questionId LONG,name VARCHAR(75) null,description VARCHAR(1000) null)";
78 public static final String TABLE_SQL_DROP = "drop table PollsChoice";
79 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
80 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsChoice"),
81 true);
82 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
83 "lock.expiration.time.com.liferay.portlet.polls.model.PollsChoice"));
84
85 public PollsChoiceModelImpl() {
86 }
87
88 public long getPrimaryKey() {
89 return _choiceId;
90 }
91
92 public void setPrimaryKey(long pk) {
93 setChoiceId(pk);
94 }
95
96 public Serializable getPrimaryKeyObj() {
97 return new Long(_choiceId);
98 }
99
100 public String getUuid() {
101 return GetterUtil.getString(_uuid);
102 }
103
104 public void setUuid(String uuid) {
105 if ((uuid != null) && (uuid != _uuid)) {
106 _uuid = uuid;
107 }
108 }
109
110 public long getChoiceId() {
111 return _choiceId;
112 }
113
114 public void setChoiceId(long choiceId) {
115 if (choiceId != _choiceId) {
116 _choiceId = choiceId;
117 }
118 }
119
120 public long getQuestionId() {
121 return _questionId;
122 }
123
124 public void setQuestionId(long questionId) {
125 if (questionId != _questionId) {
126 _questionId = questionId;
127 }
128 }
129
130 public String getName() {
131 return GetterUtil.getString(_name);
132 }
133
134 public void setName(String name) {
135 if (((name == null) && (_name != null)) ||
136 ((name != null) && (_name == null)) ||
137 ((name != null) && (_name != null) && !name.equals(_name))) {
138 _name = name;
139 }
140 }
141
142 public String getDescription() {
143 return GetterUtil.getString(_description);
144 }
145
146 public void setDescription(String description) {
147 if (((description == null) && (_description != null)) ||
148 ((description != null) && (_description == null)) ||
149 ((description != null) && (_description != null) &&
150 !description.equals(_description))) {
151 _description = description;
152 }
153 }
154
155 public PollsChoice toEscapedModel() {
156 if (isEscapedModel()) {
157 return (PollsChoice)this;
158 }
159 else {
160 PollsChoice model = new PollsChoiceImpl();
161
162 model.setEscapedModel(true);
163
164 model.setUuid(Html.escape(getUuid()));
165 model.setChoiceId(getChoiceId());
166 model.setQuestionId(getQuestionId());
167 model.setName(Html.escape(getName()));
168 model.setDescription(Html.escape(getDescription()));
169
170 model = (PollsChoice)Proxy.newProxyInstance(PollsChoice.class.getClassLoader(),
171 new Class[] { PollsChoice.class },
172 new ReadOnlyBeanHandler(model));
173
174 return model;
175 }
176 }
177
178 public Object clone() {
179 PollsChoiceImpl clone = new PollsChoiceImpl();
180
181 clone.setUuid(getUuid());
182 clone.setChoiceId(getChoiceId());
183 clone.setQuestionId(getQuestionId());
184 clone.setName(getName());
185 clone.setDescription(getDescription());
186
187 return clone;
188 }
189
190 public int compareTo(Object obj) {
191 if (obj == null) {
192 return -1;
193 }
194
195 PollsChoiceImpl pollsChoice = (PollsChoiceImpl)obj;
196
197 int value = 0;
198
199 if (getQuestionId() < pollsChoice.getQuestionId()) {
200 value = -1;
201 }
202 else if (getQuestionId() > pollsChoice.getQuestionId()) {
203 value = 1;
204 }
205 else {
206 value = 0;
207 }
208
209 if (value != 0) {
210 return value;
211 }
212
213 value = getName().compareTo(pollsChoice.getName());
214
215 if (value != 0) {
216 return value;
217 }
218
219 return 0;
220 }
221
222 public boolean equals(Object obj) {
223 if (obj == null) {
224 return false;
225 }
226
227 PollsChoiceImpl pollsChoice = null;
228
229 try {
230 pollsChoice = (PollsChoiceImpl)obj;
231 }
232 catch (ClassCastException cce) {
233 return false;
234 }
235
236 long pk = pollsChoice.getPrimaryKey();
237
238 if (getPrimaryKey() == pk) {
239 return true;
240 }
241 else {
242 return false;
243 }
244 }
245
246 public int hashCode() {
247 return (int)getPrimaryKey();
248 }
249
250 private String _uuid;
251 private long _choiceId;
252 private long _questionId;
253 private String _name;
254 private String _description;
255 }