]> git.mxchange.org Git - jcountry-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 1 Apr 2020 16:55:52 +0000 (18:55 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 1 Apr 2020 16:55:52 +0000 (18:55 +0200)
- added countryEntryUpdated entity property
- added default contructor and one with all required entity properties

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jcountry/model/data/Country.java
src/org/mxchange/jcountry/model/data/CountryData.java

index 3e096926a3817c8748bf3ed43dfb859a6b35821a..5dd02a6bc48c98fb2eb2cbc1c5c3c504b9d3125e 100644 (file)
@@ -139,6 +139,20 @@ public interface Country extends Comparable<Country>, Serializable {
         */
        void setCountryEntryCreated (final Date countryEntryCreated);
 
+       /**
+        * Getter for country entry updated timestamp
+        * <p>
+        * @return Country entry updated timestamp
+        */
+       Date getCountryEntryUpdated ();
+
+       /**
+        * Setter for country entry updated timestamp
+        * <p>
+        * @param countryEntryUpdated Country entry updated timestamp
+        */
+       void setCountryEntryUpdated (final Date countryEntryUpdated);
+
        @Override
        boolean equals (final Object object);
 
index 7e34d0ac1bec7a7a3e9a835598ca0ccc12bac082..bd0b8eda6c7e251ac1a0d663e7bf6afba582e90e 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jcountry.model.data;
 
+import java.text.MessageFormat;
 import java.util.Date;
 import java.util.Objects;
 import javax.persistence.Basic;
@@ -78,6 +79,13 @@ public class CountryData implements Country {
        @Column (name = "country_entry_created", nullable = false, updatable = false)
        private Date countryEntryCreated;
 
+       /**
+        * TImestamp when this entry has been updated
+        */
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "country_entry_updated", insertable = false)
+       private Date countryEntryUpdated;
+
        /**
         * Dial prefix to be dialed before the area/city number is dialed. In
         * Germany, this is 0.
@@ -117,6 +125,66 @@ public class CountryData implements Country {
        @Column (name = "country_phone_code", length = 2, nullable = false, updatable = false)
        private Short countryPhoneCode;
 
+       /**
+        * Default constructor, required for the JPA
+        */
+       public CountryData () {
+       }
+
+       /**
+        * Constructor with all required fields
+        * <p>
+        * @param countryAbroadDialPrefix      Abroad dial prefix
+        * @param countryCode                  2-digit country code
+        * @param countryExternalDialPrefix    External dial prefix
+        * @param countryI18nKey               I18n key
+        * @param countryIsLocalPrefixRequired Whether local prefix is required to
+        *                                     dial
+        * @param countryPhoneCode             Phone code for country
+        */
+       public CountryData (final String countryAbroadDialPrefix, final String countryCode, final String countryExternalDialPrefix, final String countryI18nKey, final Boolean countryIsLocalPrefixRequired, final Short countryPhoneCode) {
+               // Invoke default constructor first
+               this();
+
+               // Are all parameter set?
+               if (null == countryAbroadDialPrefix) {
+                       // Throw NPE
+                       throw new NullPointerException("countryAbroadDialPrefix is null"); //NOI18N
+               } else if (countryAbroadDialPrefix.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("countryAbroadDialPrefix is empty"); //NOI18N
+               } else if (null == countryCode) {
+                       // Throw NPE
+                       throw new NullPointerException("countryCode is null"); //NOI18N
+               } else if (countryCode.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("countryCode is empty"); //NOI18N
+               } else if (null == countryI18nKey) {
+                       // Throw NPE
+                       throw new NullPointerException("countryI18nKey is null"); //NOI18N
+               } else if (countryI18nKey.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("countryI18nKey is empty"); //NOI18N
+               } else if (null == countryIsLocalPrefixRequired) {
+                       // Throw NPE
+                       throw new NullPointerException("countryIsLocalPrefixRequired is null"); //NOI18N
+               } else if (null == countryPhoneCode) {
+                       // Throw NPE
+                       throw new NullPointerException("countryPhoneCode is null"); //NOI18N
+               } else if (countryPhoneCode < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("countryPhoneCode={0} is not valid, must be at least 1.", countryPhoneCode)); //NOI18N
+               }
+
+               // Set all fields
+               this.countryAbroadDialPrefix = countryAbroadDialPrefix;
+               this.countryCode = countryCode;
+               this.countryExternalDialPrefix = countryExternalDialPrefix;
+               this.countryI18nKey = countryI18nKey;
+               this.countryIsLocalPrefixRequired = countryIsLocalPrefixRequired;
+               this.countryPhoneCode = countryPhoneCode;
+       }
+
        @Override
        public int compareTo (final Country country) {
                // Check parameter on null-reference and equality to this
@@ -207,6 +275,18 @@ public class CountryData implements Country {
                this.countryEntryCreated = countryEntryCreated;
        }
 
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getCountryEntryUpdated () {
+               return this.countryEntryUpdated;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setCountryEntryUpdated (final Date countryEntryUpdated) {
+               this.countryEntryUpdated = countryEntryUpdated;
+       }
+
        @Override
        public String getCountryExternalDialPrefix () {
                return this.countryExternalDialPrefix;