]> git.mxchange.org Git - jcountry-core.git/commitdiff
Continued a bit:
authorRoland Häder <roland@mxchange.org>
Wed, 7 Sep 2016 16:01:40 +0000 (18:01 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 7 Sep 2016 16:01:40 +0000 (18:01 +0200)
- added copyAll() for e.g. EJBs to copy all (old) values and then update only new values

src/org/mxchange/jcountry/data/Country.java
src/org/mxchange/jcountry/data/CountryData.java

index 52380f2ceca88e45d1fcba5c7765e80e7e3f9332..8c8e2c71ba4bc91bf7948531c35d9a83ae915966 100644 (file)
@@ -26,6 +26,13 @@ import java.util.Calendar;
  */
 public interface Country extends Serializable {
 
+       /**
+        * Copies all entries from sounce country to this
+        * <p>
+        * @param sourceCountry Source country to copy from
+        */
+       void copyAll (final Country sourceCountry);
+
        /**
         * Getter for country code (example: 49 for Germany, 63 for Philippines)
         * <p>
@@ -120,7 +127,8 @@ public interface Country extends Serializable {
        /**
         * Setter for whether the local dial prefix is required for local calls
         * <p>
-        * @param countryIsLocalPrefixRequired Whether the local dial prefix is required
+        * @param countryIsLocalPrefixRequired Whether the local dial prefix is
+        * required
         */
        void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired);
 
index 1eb4300ef6c732cb8dffdcc33daba5a0d1be19f1..9f1bd1474b56782a8af347809c48d66502f34ed0 100644 (file)
@@ -116,6 +116,25 @@ public class CountryData implements Country {
        @Column (name = "country_phone_code", length = 2, nullable = false, updatable = false)
        private Short countryPhoneCode;
 
+       @Override
+       public void copyAll (final Country sourceCountry) {
+               // Parameter should not be null
+               if (null == sourceCountry) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceCountry is null"); //NOI18N
+               }
+
+               // Copy all
+               this.setCountryAbroadDialPrefix(sourceCountry.getCountryAbroadDialPrefix());
+               this.setCountryCode(sourceCountry.getCountryCode());
+               this.setCountryEntryCreated(sourceCountry.getCountryEntryCreated());
+               this.setCountryExternalDialPrefix(sourceCountry.getCountryExternalDialPrefix());
+               this.setCountryI18nKey(sourceCountry.getCountryI18nKey());
+               this.setCountryId(sourceCountry.getCountryId());
+               this.setCountryIsLocalPrefixRequired(sourceCountry.getCountryIsLocalPrefixRequired());
+               this.setCountryPhoneCode(sourceCountry.getCountryPhoneCode());
+       }
+
        @Override
        public boolean equals (final Object object) {
                if (this == object) {