From: Roland Häder Date: Wed, 7 Sep 2016 16:05:26 +0000 (+0200) Subject: Continued a bit: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e473bf62f32cb4a685974da095833cc19a61d80a;p=jphone-core.git Continued a bit: - added copyAll() + used it to copy only values --- diff --git a/src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java b/src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java index e9774de..0e2cf05 100644 --- a/src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java +++ b/src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java @@ -127,9 +127,15 @@ public class FaxNumber implements DialableFaxNumber { @Override public void copyAll (final DialableFaxNumber sourceNumber) { + // Validate instance + if (null == sourceNumber) { + // Throw NPE + throw new NullPointerException("sourceNumber is null"); //NOI18N + } + // Copy all this.setPhoneAreaCode(sourceNumber.getPhoneAreaCode()); - this.setPhoneCountry(sourceNumber.getPhoneCountry()); + this.getPhoneCountry().copyAll(sourceNumber.getPhoneCountry()); this.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated()); this.setPhoneId(sourceNumber.getPhoneId()); this.setPhoneNumber(sourceNumber.getPhoneNumber()); diff --git a/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java b/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java index 7411cf5..b9ca58c 100644 --- a/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java +++ b/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java @@ -127,9 +127,15 @@ public class LandLineNumber implements DialableLandLineNumber { @Override public void copyAll (final DialableLandLineNumber sourceNumber) { + // Validate instance + if (null == sourceNumber) { + // Throw NPE + throw new NullPointerException("sourceNumber is null"); //NOI18N + } + // Copy all this.setPhoneAreaCode(sourceNumber.getPhoneAreaCode()); - this.setPhoneCountry(sourceNumber.getPhoneCountry()); + this.getPhoneCountry().copyAll(sourceNumber.getPhoneCountry()); this.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated()); this.setPhoneId(sourceNumber.getPhoneId()); this.setPhoneNumber(sourceNumber.getPhoneNumber()); diff --git a/src/org/mxchange/jphone/phonenumbers/mobile/MobileNumber.java b/src/org/mxchange/jphone/phonenumbers/mobile/MobileNumber.java index ac2a0c2..d553c94 100644 --- a/src/org/mxchange/jphone/phonenumbers/mobile/MobileNumber.java +++ b/src/org/mxchange/jphone/phonenumbers/mobile/MobileNumber.java @@ -119,8 +119,14 @@ public class MobileNumber implements DialableMobileNumber { @Override public void copyAll (final DialableMobileNumber sourceNumber) { + // Validate instance + if (null == sourceNumber) { + // Throw NPE + throw new NullPointerException("sourceNumber is null"); //NOI18N + } + // Copy all - this.setMobileProvider(sourceNumber.getMobileProvider()); + this.getMobileProvider().copyAll(sourceNumber.getMobileProvider()); this.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated()); this.setPhoneId(sourceNumber.getPhoneId()); this.setPhoneNumber(sourceNumber.getPhoneNumber()); diff --git a/src/org/mxchange/jphone/phonenumbers/mobileprovider/CellphoneProvider.java b/src/org/mxchange/jphone/phonenumbers/mobileprovider/CellphoneProvider.java index dc20772..b31ce49 100644 --- a/src/org/mxchange/jphone/phonenumbers/mobileprovider/CellphoneProvider.java +++ b/src/org/mxchange/jphone/phonenumbers/mobileprovider/CellphoneProvider.java @@ -123,6 +123,23 @@ public class CellphoneProvider implements MobileProvider { this.providerMailPattern = providerMailPattern; } + @Override + public void copyAll (final MobileProvider sourceMobileProvider) { + // Parameter should not be null + if (null == sourceMobileProvider) { + // Throw NPE + throw new NullPointerException("sourceMobileProvider is null"); //NOI18N + } + + // Copy all values + this.getProviderCountry().copyAll(sourceMobileProvider.getProviderCountry()); + this.setProviderDialPrefix(sourceMobileProvider.getProviderDialPrefix()); + this.setProviderEntryCreated(sourceMobileProvider.getProviderEntryCreated()); + this.setProviderId(sourceMobileProvider.getProviderId()); + this.setProviderMailPattern(sourceMobileProvider.getProviderMailPattern()); + this.setProviderName(sourceMobileProvider.getProviderName()); + } + @Override public boolean equals (final Object object) { if (null == object) { diff --git a/src/org/mxchange/jphone/phonenumbers/mobileprovider/MobileProvider.java b/src/org/mxchange/jphone/phonenumbers/mobileprovider/MobileProvider.java index 77fe960..687ddb7 100644 --- a/src/org/mxchange/jphone/phonenumbers/mobileprovider/MobileProvider.java +++ b/src/org/mxchange/jphone/phonenumbers/mobileprovider/MobileProvider.java @@ -27,6 +27,13 @@ import org.mxchange.jcountry.data.Country; */ public interface MobileProvider extends Serializable { + /** + * Copies all values from source mobile provider to this + *

+ * @param sourceMobileProvider Source mobile provider + */ + void copyAll (final MobileProvider sourceMobileProvider); + /** * Getter for id number *