1
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.Region;
29 import com.liferay.portal.model.RegionSoap;
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
61 public class RegionModelImpl extends BaseModelImpl {
62 public static final String TABLE_NAME = "Region";
63 public static final Object[][] TABLE_COLUMNS = {
64 { "regionId", new Integer(Types.BIGINT) },
65
66
67 { "countryId", new Integer(Types.BIGINT) },
68
69
70 { "regionCode", new Integer(Types.VARCHAR) },
71
72
73 { "name", new Integer(Types.VARCHAR) },
74
75
76 { "active_", new Integer(Types.BOOLEAN) }
77 };
78 public static final String TABLE_SQL_CREATE = "create table Region (regionId LONG not null primary key,countryId LONG,regionCode VARCHAR(75) null,name VARCHAR(75) null,active_ BOOLEAN)";
79 public static final String TABLE_SQL_DROP = "drop table Region";
80 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
81 "value.object.finder.cache.enabled.com.liferay.portal.model.Region"),
82 true);
83
84 public static Region toModel(RegionSoap soapModel) {
85 Region model = new RegionImpl();
86
87 model.setRegionId(soapModel.getRegionId());
88 model.setCountryId(soapModel.getCountryId());
89 model.setRegionCode(soapModel.getRegionCode());
90 model.setName(soapModel.getName());
91 model.setActive(soapModel.getActive());
92
93 return model;
94 }
95
96 public static List<Region> toModels(RegionSoap[] soapModels) {
97 List<Region> models = new ArrayList<Region>(soapModels.length);
98
99 for (RegionSoap soapModel : soapModels) {
100 models.add(toModel(soapModel));
101 }
102
103 return models;
104 }
105
106 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
107 "lock.expiration.time.com.liferay.portal.model.Region"));
108
109 public RegionModelImpl() {
110 }
111
112 public long getPrimaryKey() {
113 return _regionId;
114 }
115
116 public void setPrimaryKey(long pk) {
117 setRegionId(pk);
118 }
119
120 public Serializable getPrimaryKeyObj() {
121 return new Long(_regionId);
122 }
123
124 public long getRegionId() {
125 return _regionId;
126 }
127
128 public void setRegionId(long regionId) {
129 if (regionId != _regionId) {
130 _regionId = regionId;
131 }
132 }
133
134 public long getCountryId() {
135 return _countryId;
136 }
137
138 public void setCountryId(long countryId) {
139 if (countryId != _countryId) {
140 _countryId = countryId;
141 }
142 }
143
144 public String getRegionCode() {
145 return GetterUtil.getString(_regionCode);
146 }
147
148 public void setRegionCode(String regionCode) {
149 if (((regionCode == null) && (_regionCode != null)) ||
150 ((regionCode != null) && (_regionCode == null)) ||
151 ((regionCode != null) && (_regionCode != null) &&
152 !regionCode.equals(_regionCode))) {
153 _regionCode = regionCode;
154 }
155 }
156
157 public String getName() {
158 return GetterUtil.getString(_name);
159 }
160
161 public void setName(String name) {
162 if (((name == null) && (_name != null)) ||
163 ((name != null) && (_name == null)) ||
164 ((name != null) && (_name != null) && !name.equals(_name))) {
165 _name = name;
166 }
167 }
168
169 public boolean getActive() {
170 return _active;
171 }
172
173 public boolean isActive() {
174 return _active;
175 }
176
177 public void setActive(boolean active) {
178 if (active != _active) {
179 _active = active;
180 }
181 }
182
183 public Region toEscapedModel() {
184 if (isEscapedModel()) {
185 return (Region)this;
186 }
187 else {
188 Region model = new RegionImpl();
189
190 model.setEscapedModel(true);
191
192 model.setRegionId(getRegionId());
193 model.setCountryId(getCountryId());
194 model.setRegionCode(HtmlUtil.escape(getRegionCode()));
195 model.setName(HtmlUtil.escape(getName()));
196 model.setActive(getActive());
197
198 model = (Region)Proxy.newProxyInstance(Region.class.getClassLoader(),
199 new Class[] { Region.class }, new ReadOnlyBeanHandler(model));
200
201 return model;
202 }
203 }
204
205 public Object clone() {
206 RegionImpl clone = new RegionImpl();
207
208 clone.setRegionId(getRegionId());
209 clone.setCountryId(getCountryId());
210 clone.setRegionCode(getRegionCode());
211 clone.setName(getName());
212 clone.setActive(getActive());
213
214 return clone;
215 }
216
217 public int compareTo(Object obj) {
218 if (obj == null) {
219 return -1;
220 }
221
222 RegionImpl region = (RegionImpl)obj;
223
224 int value = 0;
225
226 value = getName().compareTo(region.getName());
227
228 if (value != 0) {
229 return value;
230 }
231
232 return 0;
233 }
234
235 public boolean equals(Object obj) {
236 if (obj == null) {
237 return false;
238 }
239
240 RegionImpl region = null;
241
242 try {
243 region = (RegionImpl)obj;
244 }
245 catch (ClassCastException cce) {
246 return false;
247 }
248
249 long pk = region.getPrimaryKey();
250
251 if (getPrimaryKey() == pk) {
252 return true;
253 }
254 else {
255 return false;
256 }
257 }
258
259 public int hashCode() {
260 return (int)getPrimaryKey();
261 }
262
263 private long _regionId;
264 private long _countryId;
265 private String _regionCode;
266 private String _name;
267 private boolean _active;
268 }