001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.expando.kernel.model.ExpandoBridge;
020    import com.liferay.expando.kernel.util.ExpandoBridgeFactoryUtil;
021    
022    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
023    import com.liferay.portal.kernel.json.JSON;
024    import com.liferay.portal.kernel.model.CacheModel;
025    import com.liferay.portal.kernel.model.Country;
026    import com.liferay.portal.kernel.model.CountryModel;
027    import com.liferay.portal.kernel.model.CountrySoap;
028    import com.liferay.portal.kernel.model.impl.BaseModelImpl;
029    import com.liferay.portal.kernel.service.ServiceContext;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.ProxyUtil;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    
035    import java.io.Serializable;
036    
037    import java.sql.Types;
038    
039    import java.util.ArrayList;
040    import java.util.HashMap;
041    import java.util.List;
042    import java.util.Map;
043    
044    /**
045     * The base model implementation for the Country service. Represents a row in the "Country" database table, with each column mapped to a property of this class.
046     *
047     * <p>
048     * This implementation and its corresponding interface {@link CountryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CountryImpl}.
049     * </p>
050     *
051     * @author Brian Wing Shun Chan
052     * @see CountryImpl
053     * @see Country
054     * @see CountryModel
055     * @generated
056     */
057    @JSON(strict = true)
058    @ProviderType
059    public class CountryModelImpl extends BaseModelImpl<Country>
060            implements CountryModel {
061            /*
062             * NOTE FOR DEVELOPERS:
063             *
064             * Never modify or reference this class directly. All methods that expect a country model instance should use the {@link Country} interface instead.
065             */
066            public static final String TABLE_NAME = "Country";
067            public static final Object[][] TABLE_COLUMNS = {
068                            { "mvccVersion", Types.BIGINT },
069                            { "countryId", Types.BIGINT },
070                            { "name", Types.VARCHAR },
071                            { "a2", Types.VARCHAR },
072                            { "a3", Types.VARCHAR },
073                            { "number_", Types.VARCHAR },
074                            { "idd_", Types.VARCHAR },
075                            { "zipRequired", Types.BOOLEAN },
076                            { "active_", Types.BOOLEAN }
077                    };
078            public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
079    
080            static {
081                    TABLE_COLUMNS_MAP.put("mvccVersion", Types.BIGINT);
082                    TABLE_COLUMNS_MAP.put("countryId", Types.BIGINT);
083                    TABLE_COLUMNS_MAP.put("name", Types.VARCHAR);
084                    TABLE_COLUMNS_MAP.put("a2", Types.VARCHAR);
085                    TABLE_COLUMNS_MAP.put("a3", Types.VARCHAR);
086                    TABLE_COLUMNS_MAP.put("number_", Types.VARCHAR);
087                    TABLE_COLUMNS_MAP.put("idd_", Types.VARCHAR);
088                    TABLE_COLUMNS_MAP.put("zipRequired", Types.BOOLEAN);
089                    TABLE_COLUMNS_MAP.put("active_", Types.BOOLEAN);
090            }
091    
092            public static final String TABLE_SQL_CREATE = "create table Country (mvccVersion LONG default 0 not null,countryId LONG not null primary key,name VARCHAR(75) null,a2 VARCHAR(75) null,a3 VARCHAR(75) null,number_ VARCHAR(75) null,idd_ VARCHAR(75) null,zipRequired BOOLEAN,active_ BOOLEAN)";
093            public static final String TABLE_SQL_DROP = "drop table Country";
094            public static final String ORDER_BY_JPQL = " ORDER BY country.name ASC";
095            public static final String ORDER_BY_SQL = " ORDER BY Country.name ASC";
096            public static final String DATA_SOURCE = "liferayDataSource";
097            public static final String SESSION_FACTORY = "liferaySessionFactory";
098            public static final String TX_MANAGER = "liferayTransactionManager";
099            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
100                                    "value.object.entity.cache.enabled.com.liferay.portal.kernel.model.Country"),
101                            true);
102            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
103                                    "value.object.finder.cache.enabled.com.liferay.portal.kernel.model.Country"),
104                            true);
105            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
106                                    "value.object.column.bitmask.enabled.com.liferay.portal.kernel.model.Country"),
107                            true);
108            public static final long A2_COLUMN_BITMASK = 1L;
109            public static final long A3_COLUMN_BITMASK = 2L;
110            public static final long ACTIVE_COLUMN_BITMASK = 4L;
111            public static final long NAME_COLUMN_BITMASK = 8L;
112    
113            /**
114             * Converts the soap model instance into a normal model instance.
115             *
116             * @param soapModel the soap model instance to convert
117             * @return the normal model instance
118             */
119            public static Country toModel(CountrySoap soapModel) {
120                    if (soapModel == null) {
121                            return null;
122                    }
123    
124                    Country model = new CountryImpl();
125    
126                    model.setMvccVersion(soapModel.getMvccVersion());
127                    model.setCountryId(soapModel.getCountryId());
128                    model.setName(soapModel.getName());
129                    model.setA2(soapModel.getA2());
130                    model.setA3(soapModel.getA3());
131                    model.setNumber(soapModel.getNumber());
132                    model.setIdd(soapModel.getIdd());
133                    model.setZipRequired(soapModel.getZipRequired());
134                    model.setActive(soapModel.getActive());
135    
136                    return model;
137            }
138    
139            /**
140             * Converts the soap model instances into normal model instances.
141             *
142             * @param soapModels the soap model instances to convert
143             * @return the normal model instances
144             */
145            public static List<Country> toModels(CountrySoap[] soapModels) {
146                    if (soapModels == null) {
147                            return null;
148                    }
149    
150                    List<Country> models = new ArrayList<Country>(soapModels.length);
151    
152                    for (CountrySoap soapModel : soapModels) {
153                            models.add(toModel(soapModel));
154                    }
155    
156                    return models;
157            }
158    
159            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
160                                    "lock.expiration.time.com.liferay.portal.kernel.model.Country"));
161    
162            public CountryModelImpl() {
163            }
164    
165            @Override
166            public long getPrimaryKey() {
167                    return _countryId;
168            }
169    
170            @Override
171            public void setPrimaryKey(long primaryKey) {
172                    setCountryId(primaryKey);
173            }
174    
175            @Override
176            public Serializable getPrimaryKeyObj() {
177                    return _countryId;
178            }
179    
180            @Override
181            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
182                    setPrimaryKey(((Long)primaryKeyObj).longValue());
183            }
184    
185            @Override
186            public Class<?> getModelClass() {
187                    return Country.class;
188            }
189    
190            @Override
191            public String getModelClassName() {
192                    return Country.class.getName();
193            }
194    
195            @Override
196            public Map<String, Object> getModelAttributes() {
197                    Map<String, Object> attributes = new HashMap<String, Object>();
198    
199                    attributes.put("mvccVersion", getMvccVersion());
200                    attributes.put("countryId", getCountryId());
201                    attributes.put("name", getName());
202                    attributes.put("a2", getA2());
203                    attributes.put("a3", getA3());
204                    attributes.put("number", getNumber());
205                    attributes.put("idd", getIdd());
206                    attributes.put("zipRequired", getZipRequired());
207                    attributes.put("active", getActive());
208    
209                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
210                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
211    
212                    return attributes;
213            }
214    
215            @Override
216            public void setModelAttributes(Map<String, Object> attributes) {
217                    Long mvccVersion = (Long)attributes.get("mvccVersion");
218    
219                    if (mvccVersion != null) {
220                            setMvccVersion(mvccVersion);
221                    }
222    
223                    Long countryId = (Long)attributes.get("countryId");
224    
225                    if (countryId != null) {
226                            setCountryId(countryId);
227                    }
228    
229                    String name = (String)attributes.get("name");
230    
231                    if (name != null) {
232                            setName(name);
233                    }
234    
235                    String a2 = (String)attributes.get("a2");
236    
237                    if (a2 != null) {
238                            setA2(a2);
239                    }
240    
241                    String a3 = (String)attributes.get("a3");
242    
243                    if (a3 != null) {
244                            setA3(a3);
245                    }
246    
247                    String number = (String)attributes.get("number");
248    
249                    if (number != null) {
250                            setNumber(number);
251                    }
252    
253                    String idd = (String)attributes.get("idd");
254    
255                    if (idd != null) {
256                            setIdd(idd);
257                    }
258    
259                    Boolean zipRequired = (Boolean)attributes.get("zipRequired");
260    
261                    if (zipRequired != null) {
262                            setZipRequired(zipRequired);
263                    }
264    
265                    Boolean active = (Boolean)attributes.get("active");
266    
267                    if (active != null) {
268                            setActive(active);
269                    }
270            }
271    
272            @JSON
273            @Override
274            public long getMvccVersion() {
275                    return _mvccVersion;
276            }
277    
278            @Override
279            public void setMvccVersion(long mvccVersion) {
280                    _mvccVersion = mvccVersion;
281            }
282    
283            @JSON
284            @Override
285            public long getCountryId() {
286                    return _countryId;
287            }
288    
289            @Override
290            public void setCountryId(long countryId) {
291                    _countryId = countryId;
292            }
293    
294            @JSON
295            @Override
296            public String getName() {
297                    if (_name == null) {
298                            return StringPool.BLANK;
299                    }
300                    else {
301                            return _name;
302                    }
303            }
304    
305            @Override
306            public void setName(String name) {
307                    _columnBitmask = -1L;
308    
309                    if (_originalName == null) {
310                            _originalName = _name;
311                    }
312    
313                    _name = name;
314            }
315    
316            public String getOriginalName() {
317                    return GetterUtil.getString(_originalName);
318            }
319    
320            @JSON
321            @Override
322            public String getA2() {
323                    if (_a2 == null) {
324                            return StringPool.BLANK;
325                    }
326                    else {
327                            return _a2;
328                    }
329            }
330    
331            @Override
332            public void setA2(String a2) {
333                    _columnBitmask |= A2_COLUMN_BITMASK;
334    
335                    if (_originalA2 == null) {
336                            _originalA2 = _a2;
337                    }
338    
339                    _a2 = a2;
340            }
341    
342            public String getOriginalA2() {
343                    return GetterUtil.getString(_originalA2);
344            }
345    
346            @JSON
347            @Override
348            public String getA3() {
349                    if (_a3 == null) {
350                            return StringPool.BLANK;
351                    }
352                    else {
353                            return _a3;
354                    }
355            }
356    
357            @Override
358            public void setA3(String a3) {
359                    _columnBitmask |= A3_COLUMN_BITMASK;
360    
361                    if (_originalA3 == null) {
362                            _originalA3 = _a3;
363                    }
364    
365                    _a3 = a3;
366            }
367    
368            public String getOriginalA3() {
369                    return GetterUtil.getString(_originalA3);
370            }
371    
372            @JSON
373            @Override
374            public String getNumber() {
375                    if (_number == null) {
376                            return StringPool.BLANK;
377                    }
378                    else {
379                            return _number;
380                    }
381            }
382    
383            @Override
384            public void setNumber(String number) {
385                    _number = number;
386            }
387    
388            @JSON
389            @Override
390            public String getIdd() {
391                    if (_idd == null) {
392                            return StringPool.BLANK;
393                    }
394                    else {
395                            return _idd;
396                    }
397            }
398    
399            @Override
400            public void setIdd(String idd) {
401                    _idd = idd;
402            }
403    
404            @JSON
405            @Override
406            public boolean getZipRequired() {
407                    return _zipRequired;
408            }
409    
410            @Override
411            public boolean isZipRequired() {
412                    return _zipRequired;
413            }
414    
415            @Override
416            public void setZipRequired(boolean zipRequired) {
417                    _zipRequired = zipRequired;
418            }
419    
420            @JSON
421            @Override
422            public boolean getActive() {
423                    return _active;
424            }
425    
426            @Override
427            public boolean isActive() {
428                    return _active;
429            }
430    
431            @Override
432            public void setActive(boolean active) {
433                    _columnBitmask |= ACTIVE_COLUMN_BITMASK;
434    
435                    if (!_setOriginalActive) {
436                            _setOriginalActive = true;
437    
438                            _originalActive = _active;
439                    }
440    
441                    _active = active;
442            }
443    
444            public boolean getOriginalActive() {
445                    return _originalActive;
446            }
447    
448            public long getColumnBitmask() {
449                    return _columnBitmask;
450            }
451    
452            @Override
453            public ExpandoBridge getExpandoBridge() {
454                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
455                            Country.class.getName(), getPrimaryKey());
456            }
457    
458            @Override
459            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
460                    ExpandoBridge expandoBridge = getExpandoBridge();
461    
462                    expandoBridge.setAttributes(serviceContext);
463            }
464    
465            @Override
466            public Country toEscapedModel() {
467                    if (_escapedModel == null) {
468                            _escapedModel = (Country)ProxyUtil.newProxyInstance(_classLoader,
469                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
470                    }
471    
472                    return _escapedModel;
473            }
474    
475            @Override
476            public Object clone() {
477                    CountryImpl countryImpl = new CountryImpl();
478    
479                    countryImpl.setMvccVersion(getMvccVersion());
480                    countryImpl.setCountryId(getCountryId());
481                    countryImpl.setName(getName());
482                    countryImpl.setA2(getA2());
483                    countryImpl.setA3(getA3());
484                    countryImpl.setNumber(getNumber());
485                    countryImpl.setIdd(getIdd());
486                    countryImpl.setZipRequired(getZipRequired());
487                    countryImpl.setActive(getActive());
488    
489                    countryImpl.resetOriginalValues();
490    
491                    return countryImpl;
492            }
493    
494            @Override
495            public int compareTo(Country country) {
496                    int value = 0;
497    
498                    value = getName().compareTo(country.getName());
499    
500                    if (value != 0) {
501                            return value;
502                    }
503    
504                    return 0;
505            }
506    
507            @Override
508            public boolean equals(Object obj) {
509                    if (this == obj) {
510                            return true;
511                    }
512    
513                    if (!(obj instanceof Country)) {
514                            return false;
515                    }
516    
517                    Country country = (Country)obj;
518    
519                    long primaryKey = country.getPrimaryKey();
520    
521                    if (getPrimaryKey() == primaryKey) {
522                            return true;
523                    }
524                    else {
525                            return false;
526                    }
527            }
528    
529            @Override
530            public int hashCode() {
531                    return (int)getPrimaryKey();
532            }
533    
534            @Override
535            public boolean isEntityCacheEnabled() {
536                    return ENTITY_CACHE_ENABLED;
537            }
538    
539            @Override
540            public boolean isFinderCacheEnabled() {
541                    return FINDER_CACHE_ENABLED;
542            }
543    
544            @Override
545            public void resetOriginalValues() {
546                    CountryModelImpl countryModelImpl = this;
547    
548                    countryModelImpl._originalName = countryModelImpl._name;
549    
550                    countryModelImpl._originalA2 = countryModelImpl._a2;
551    
552                    countryModelImpl._originalA3 = countryModelImpl._a3;
553    
554                    countryModelImpl._originalActive = countryModelImpl._active;
555    
556                    countryModelImpl._setOriginalActive = false;
557    
558                    countryModelImpl._columnBitmask = 0;
559            }
560    
561            @Override
562            public CacheModel<Country> toCacheModel() {
563                    CountryCacheModel countryCacheModel = new CountryCacheModel();
564    
565                    countryCacheModel.mvccVersion = getMvccVersion();
566    
567                    countryCacheModel.countryId = getCountryId();
568    
569                    countryCacheModel.name = getName();
570    
571                    String name = countryCacheModel.name;
572    
573                    if ((name != null) && (name.length() == 0)) {
574                            countryCacheModel.name = null;
575                    }
576    
577                    countryCacheModel.a2 = getA2();
578    
579                    String a2 = countryCacheModel.a2;
580    
581                    if ((a2 != null) && (a2.length() == 0)) {
582                            countryCacheModel.a2 = null;
583                    }
584    
585                    countryCacheModel.a3 = getA3();
586    
587                    String a3 = countryCacheModel.a3;
588    
589                    if ((a3 != null) && (a3.length() == 0)) {
590                            countryCacheModel.a3 = null;
591                    }
592    
593                    countryCacheModel.number = getNumber();
594    
595                    String number = countryCacheModel.number;
596    
597                    if ((number != null) && (number.length() == 0)) {
598                            countryCacheModel.number = null;
599                    }
600    
601                    countryCacheModel.idd = getIdd();
602    
603                    String idd = countryCacheModel.idd;
604    
605                    if ((idd != null) && (idd.length() == 0)) {
606                            countryCacheModel.idd = null;
607                    }
608    
609                    countryCacheModel.zipRequired = getZipRequired();
610    
611                    countryCacheModel.active = getActive();
612    
613                    return countryCacheModel;
614            }
615    
616            @Override
617            public String toString() {
618                    StringBundler sb = new StringBundler(19);
619    
620                    sb.append("{mvccVersion=");
621                    sb.append(getMvccVersion());
622                    sb.append(", countryId=");
623                    sb.append(getCountryId());
624                    sb.append(", name=");
625                    sb.append(getName());
626                    sb.append(", a2=");
627                    sb.append(getA2());
628                    sb.append(", a3=");
629                    sb.append(getA3());
630                    sb.append(", number=");
631                    sb.append(getNumber());
632                    sb.append(", idd=");
633                    sb.append(getIdd());
634                    sb.append(", zipRequired=");
635                    sb.append(getZipRequired());
636                    sb.append(", active=");
637                    sb.append(getActive());
638                    sb.append("}");
639    
640                    return sb.toString();
641            }
642    
643            @Override
644            public String toXmlString() {
645                    StringBundler sb = new StringBundler(31);
646    
647                    sb.append("<model><model-name>");
648                    sb.append("com.liferay.portal.kernel.model.Country");
649                    sb.append("</model-name>");
650    
651                    sb.append(
652                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
653                    sb.append(getMvccVersion());
654                    sb.append("]]></column-value></column>");
655                    sb.append(
656                            "<column><column-name>countryId</column-name><column-value><![CDATA[");
657                    sb.append(getCountryId());
658                    sb.append("]]></column-value></column>");
659                    sb.append(
660                            "<column><column-name>name</column-name><column-value><![CDATA[");
661                    sb.append(getName());
662                    sb.append("]]></column-value></column>");
663                    sb.append(
664                            "<column><column-name>a2</column-name><column-value><![CDATA[");
665                    sb.append(getA2());
666                    sb.append("]]></column-value></column>");
667                    sb.append(
668                            "<column><column-name>a3</column-name><column-value><![CDATA[");
669                    sb.append(getA3());
670                    sb.append("]]></column-value></column>");
671                    sb.append(
672                            "<column><column-name>number</column-name><column-value><![CDATA[");
673                    sb.append(getNumber());
674                    sb.append("]]></column-value></column>");
675                    sb.append(
676                            "<column><column-name>idd</column-name><column-value><![CDATA[");
677                    sb.append(getIdd());
678                    sb.append("]]></column-value></column>");
679                    sb.append(
680                            "<column><column-name>zipRequired</column-name><column-value><![CDATA[");
681                    sb.append(getZipRequired());
682                    sb.append("]]></column-value></column>");
683                    sb.append(
684                            "<column><column-name>active</column-name><column-value><![CDATA[");
685                    sb.append(getActive());
686                    sb.append("]]></column-value></column>");
687    
688                    sb.append("</model>");
689    
690                    return sb.toString();
691            }
692    
693            private static final ClassLoader _classLoader = Country.class.getClassLoader();
694            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
695                            Country.class
696                    };
697            private long _mvccVersion;
698            private long _countryId;
699            private String _name;
700            private String _originalName;
701            private String _a2;
702            private String _originalA2;
703            private String _a3;
704            private String _originalA3;
705            private String _number;
706            private String _idd;
707            private boolean _zipRequired;
708            private boolean _active;
709            private boolean _originalActive;
710            private boolean _setOriginalActive;
711            private long _columnBitmask;
712            private Country _escapedModel;
713    }