From 7da8d890cf8f25e1449bcbddb0716f1d43722e92 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 7 Sep 2016 18:01:40 +0200 Subject: [PATCH] Continued a bit: - added copyAll() for e.g. EJBs to copy all (old) values and then update only new values --- src/org/mxchange/jcountry/data/Country.java | 10 +++++++++- .../mxchange/jcountry/data/CountryData.java | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/org/mxchange/jcountry/data/Country.java b/src/org/mxchange/jcountry/data/Country.java index 52380f2..8c8e2c7 100644 --- a/src/org/mxchange/jcountry/data/Country.java +++ b/src/org/mxchange/jcountry/data/Country.java @@ -26,6 +26,13 @@ import java.util.Calendar; */ public interface Country extends Serializable { + /** + * Copies all entries from sounce country to this + *

+ * @param sourceCountry Source country to copy from + */ + void copyAll (final Country sourceCountry); + /** * Getter for country code (example: 49 for Germany, 63 for Philippines) *

@@ -120,7 +127,8 @@ public interface Country extends Serializable { /** * Setter for whether the local dial prefix is required for local calls *

- * @param countryIsLocalPrefixRequired Whether the local dial prefix is required + * @param countryIsLocalPrefixRequired Whether the local dial prefix is + * required */ void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired); diff --git a/src/org/mxchange/jcountry/data/CountryData.java b/src/org/mxchange/jcountry/data/CountryData.java index 1eb4300..9f1bd14 100644 --- a/src/org/mxchange/jcountry/data/CountryData.java +++ b/src/org/mxchange/jcountry/data/CountryData.java @@ -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) { -- 2.39.5