]> git.mxchange.org Git - jphone-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 6 Oct 2022 13:59:58 +0000 (15:59 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 6 Oct 2022 13:59:58 +0000 (15:59 +0200)
- renamed utility classes *s to *Utils
- moved them in their own package (all in one)

src/org/mxchange/jphone/model/phonenumbers/fax/FaxNumber.java
src/org/mxchange/jphone/model/phonenumbers/fax/FaxNumbers.java [deleted file]
src/org/mxchange/jphone/model/phonenumbers/landline/LandLineNumbers.java [deleted file]
src/org/mxchange/jphone/model/phonenumbers/mobile/MobileNumber.java
src/org/mxchange/jphone/model/phonenumbers/mobile/MobileNumbers.java [deleted file]
src/org/mxchange/jphone/model/phonenumbers/mobileprovider/CellphoneProvider.java
src/org/mxchange/jphone/model/phonenumbers/mobileprovider/MobileProviders.java [deleted file]
src/org/mxchange/jphone/model/utils/FaxNumberUtils.java [new file with mode: 0644]
src/org/mxchange/jphone/model/utils/LandLineNumberUtils.java [new file with mode: 0644]
src/org/mxchange/jphone/model/utils/MobileNumberUtils.java [new file with mode: 0644]
src/org/mxchange/jphone/model/utils/MobileProviderUtils.java [new file with mode: 0644]

index 0adc73504c59ecff85d7a67433037477a270b5c4..431caefc7de08fc1bf57045918ffa05a4834bd35 100644 (file)
@@ -37,6 +37,7 @@ import javax.persistence.Transient;
 import org.mxchange.jcoreutils.Comparables;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jcountry.model.data.CountryData;
+import org.mxchange.jcountry.model.utils.CountryUtils;
 
 /**
  * A POJO for dialable fax numbers
@@ -151,12 +152,12 @@ public class FaxNumber implements DialableFaxNumber {
        }
 
        @Override
-       public int compareTo (final DialableFaxNumber otherNumber) {
+       public int compareTo (final DialableFaxNumber faxNumber) {
                // Is the parameter given?
-               if (null == otherNumber) {
+               if (null == faxNumber) {
                        // Throw NPE
-                       throw new NullPointerException("otherNumber is null"); //NOI18N
-               } else if (otherNumber.equals(this)) {
+                       throw new NullPointerException("faxNumber is null"); //NOI18N
+               } else if (Objects.equals(this, faxNumber)) {
                        // Same object
                        return 0;
                }
@@ -164,11 +165,11 @@ public class FaxNumber implements DialableFaxNumber {
                // Init comparisons
                final int[] comparators = {
                        // First country
-                       this.getPhoneCountry().compareTo(otherNumber.getPhoneCountry()),
+                       CountryUtils.compare(this.getPhoneCountry(), faxNumber.getPhoneCountry()),
                        // Next area code
-                       this.getPhoneAreaCode().compareTo(otherNumber.getPhoneAreaCode()),
+                       this.getPhoneAreaCode().compareTo(faxNumber.getPhoneAreaCode()),
                        // Last number
-                       this.getPhoneNumber().compareTo(otherNumber.getPhoneNumber())
+                       this.getPhoneNumber().compareTo(faxNumber.getPhoneNumber())
                };
 
                // Check all values
diff --git a/src/org/mxchange/jphone/model/phonenumbers/fax/FaxNumbers.java b/src/org/mxchange/jphone/model/phonenumbers/fax/FaxNumbers.java
deleted file mode 100644 (file)
index 2998512..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2017 - 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jphone.model.phonenumbers.fax;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-/**
- * An utilities class for fax numbers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class FaxNumbers implements Serializable {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 1_948_653_672_761L;
-
-       /**
-        * Copy all fields from source object to this
-        * <p>
-        * @param sourceNumber Source number object
-        * @param targetNumber Target number object
-        */
-       public static void copyFaxNumberData (final DialableFaxNumber sourceNumber, final DialableFaxNumber targetNumber) {
-               // Validate instance
-               if (null == sourceNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("sourceNumber is null"); //NOI18N
-               } else if (null == targetNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("targetNumber is null"); //NOI18N
-               } else if (Objects.equals(sourceNumber, targetNumber)) {
-                       // Is exactly the same!
-                       throw new IllegalArgumentException("sourcerNumber and targetNumber are the same."); //NOI18N
-               }
-
-               // Copy all
-               targetNumber.setPhoneAreaCode(sourceNumber.getPhoneAreaCode());
-               targetNumber.setPhoneCountry(sourceNumber.getPhoneCountry());
-               targetNumber.setPhoneId(sourceNumber.getPhoneId());
-               targetNumber.setPhoneNumber(sourceNumber.getPhoneNumber());
-       }
-
-       /**
-        * Checks if both are the same
-        * <p>
-        * @param faxNumber   First fax number
-        * @param otherNumber Second fax number
-        * <p>
-        * @return Whether both are the same
-        */
-       public static boolean isSameFaxNumber (final DialableFaxNumber faxNumber, DialableFaxNumber otherNumber) {
-               // Test object equality first
-               if (Objects.equals(faxNumber, otherNumber)) {
-                       // Both the same object (null/null or same object)
-                       return true;
-               } else if (((null == faxNumber) && (otherNumber instanceof DialableFaxNumber)) || ((null == otherNumber) && (faxNumber instanceof DialableFaxNumber))) {
-                       // One is null the other not
-                       return false;
-               }
-               // Now compare deeper
-               final boolean sameCountry = Objects.equals(faxNumber.getPhoneCountry(), otherNumber.getPhoneCountry());
-               final boolean sameAreaCode = Objects.equals(faxNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode());
-               final boolean sameNumber = Objects.equals(faxNumber.getPhoneNumber(), otherNumber.getPhoneNumber());
-               // All are the same?
-               return sameCountry && sameAreaCode && sameNumber;
-       }
-
-       /**
-        * No constructor for utilities classes
-        */
-       private FaxNumbers () {
-       }
-
-}
diff --git a/src/org/mxchange/jphone/model/phonenumbers/landline/LandLineNumbers.java b/src/org/mxchange/jphone/model/phonenumbers/landline/LandLineNumbers.java
deleted file mode 100644 (file)
index 769069d..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2017 - 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with targetNumber program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jphone.model.phonenumbers.landline;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-/**
- * An utilities class for land-line numbers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class LandLineNumbers implements Serializable {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 18_698_467_372_167_561L;
-
-       /**
-        * Copy all fields from source object to this
-        * <p>
-        * @param sourceNumber Source number object
-        * @param targetNumber Target number object
-        */
-       public static void copyLandLineNumberData (final DialableLandLineNumber sourceNumber, final DialableLandLineNumber targetNumber) {
-               // Validate instance
-               if (null == sourceNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("sourceNumber is null"); //NOI18N
-               } else if (null == targetNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("targetNumber is null"); //NOI18N
-               } else if (Objects.equals(sourceNumber, targetNumber)) {
-                       // Is exactly the same!
-                       throw new IllegalArgumentException("sourcerNumber and targetNumber are the same."); //NOI18N
-               }
-
-               // Copy all
-               targetNumber.setPhoneAreaCode(sourceNumber.getPhoneAreaCode());
-               targetNumber.setPhoneCountry(sourceNumber.getPhoneCountry());
-               targetNumber.setPhoneId(sourceNumber.getPhoneId());
-               targetNumber.setPhoneNumber(sourceNumber.getPhoneNumber());
-       }
-
-       /**
-        * Checks if both are the same
-        * <p>
-        * @param landLineNumber First land-line number
-        * @param otherNumber    Second land-line number
-        * <p>
-        * @return Whether both are the same
-        */
-       public static boolean isSameLandLineNumber (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber otherNumber) {
-               // Test object equality first
-               if (Objects.equals(landLineNumber, otherNumber)) {
-                       // Both the same object (null/null or same object)
-                       return true;
-               } else if (((null == landLineNumber) && (otherNumber instanceof DialableLandLineNumber)) || ((null == otherNumber) && (landLineNumber instanceof DialableLandLineNumber))) {
-                       // One is null the other not
-                       return false;
-               }
-               // Now compare deeper
-               final boolean sameCountry = Objects.equals(landLineNumber.getPhoneCountry(), otherNumber.getPhoneCountry());
-               final boolean sameAreaCode = Objects.equals(landLineNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode());
-               final boolean sameNumber = Objects.equals(landLineNumber.getPhoneNumber(), otherNumber.getPhoneNumber());
-               // All are the same?
-               return sameCountry && sameAreaCode && sameNumber;
-       }
-
-       /**
-        * No constructor for utilities classes
-        */
-       private LandLineNumbers () {
-       }
-
-}
index 1aa1c51c2a04a4fad23d28f8a68584be1f64481d..eb369b6e830e7652fe71f414bd351fc6676783ba 100644 (file)
@@ -35,8 +35,10 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 import org.mxchange.jcoreutils.Comparables;
+import org.mxchange.jcoreutils.SafeNumberUtils;
 import org.mxchange.jphone.model.phonenumbers.mobileprovider.CellphoneProvider;
 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jphone.model.utils.MobileProviderUtils;
 
 /**
  * A POJO for dialable mobile numbers
@@ -149,9 +151,9 @@ public class MobileNumber implements DialableMobileNumber {
                // Init comparisons
                final int[] comparators = {
                        // First compare provider
-                       this.getMobileProvider().compareTo(otherNumber.getMobileProvider()),
+                       MobileProviderUtils.compare(this.getMobileProvider(), otherNumber.getMobileProvider()),
                        // Last number
-                       this.getMobileNumber().compareTo(otherNumber.getMobileNumber())
+                       SafeNumberUtils.compare(this.getMobileNumber(), otherNumber.getMobileNumber())
                };
 
                // Check all values
diff --git a/src/org/mxchange/jphone/model/phonenumbers/mobile/MobileNumbers.java b/src/org/mxchange/jphone/model/phonenumbers/mobile/MobileNumbers.java
deleted file mode 100644 (file)
index 1e139b6..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2017 - 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with targetNumber program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jphone.model.phonenumbers.mobile;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-/**
- * An utilities class for mobile numbers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class MobileNumbers implements Serializable {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 291_608_496_882_761L;
-
-       /**
-        * Copy all fields from source object to this
-        * <p>
-        * @param sourceNumber Source number object
-        * @param targetNumber Target number object
-        */
-       public static void copyMobileNumberData (final DialableMobileNumber sourceNumber, final DialableMobileNumber targetNumber) {
-               // Validate instance
-               if (null == sourceNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("sourceNumber is null"); //NOI18N
-               } else if (null == targetNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("targetNumber is null"); //NOI18N
-               } else if (Objects.equals(sourceNumber, targetNumber)) {
-                       // Is exactly the same!
-                       throw new IllegalArgumentException("sourcerNumber and targetNumber are the same."); //NOI18N
-               }
-
-               // Copy all fields
-               targetNumber.setMobileProvider(sourceNumber.getMobileProvider());
-               targetNumber.setMobileId(sourceNumber.getMobileId());
-               targetNumber.setMobileNumber(sourceNumber.getMobileNumber());
-       }
-
-       /**
-        * Checks if both are the same
-        * <p>
-        * @param mobileNumber Mobile number 1
-        * @param otherNumber  Mobile number 2
-        * <p>
-        * @return Whether both are the same number
-        */
-       public static boolean isSameMobileNumber (final DialableMobileNumber mobileNumber, final DialableMobileNumber otherNumber) {
-               // Test object equality first
-               if (Objects.equals(mobileNumber, otherNumber)) {
-                       // Both the same object (null/null or same object)
-                       return true;
-               } else if (((null == mobileNumber) && (otherNumber instanceof DialableMobileNumber)) || ((null == otherNumber) && (mobileNumber instanceof DialableMobileNumber))) {
-                       // One is null the other not
-                       return false;
-               }
-               // Now compare deeper
-               final boolean sameProvider = Objects.equals(mobileNumber.getMobileProvider(), otherNumber.getMobileProvider());
-               final boolean sameNumber = Objects.equals(mobileNumber.getMobileNumber(), otherNumber.getMobileNumber());
-               // All are the same?
-               return sameProvider && sameNumber;
-       }
-
-       /**
-        * No constructor for utilities classes
-        */
-       private MobileNumbers () {
-       }
-
-}
index 5b263891ec8614fdc91efa8f179bd490464c8b86..e58d2d70055f11cfd687ed0fb20816efdd529db3 100644 (file)
@@ -36,8 +36,10 @@ import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 import org.apache.commons.lang3.StringUtils;
 import org.mxchange.jcoreutils.Comparables;
+import org.mxchange.jcoreutils.SafeNumberUtils;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jcountry.model.data.CountryData;
+import org.mxchange.jcountry.model.utils.CountryUtils;
 
 /**
  * A POJO for mobile providers
@@ -164,24 +166,26 @@ public class CellphoneProvider implements MobileProvider {
        }
 
        @Override
-       public int compareTo (final MobileProvider otherProvider) {
+       public int compareTo (final MobileProvider provider) {
                // Is the parameter given?
-               if (null == otherProvider) {
+               if (null == provider) {
                        // Throw NPE
-                       throw new NullPointerException("otherProvider is null"); //NOI18N
-               } else if (otherProvider.equals(this)) {
+                       throw new NullPointerException("Parameter 'provider' is null"); //NOI18N
+               } else if (provider.equals(this)) {
                        // Same object
                        return 0;
                }
 
                // Init comparisons
                final int[] comparators = {
-                       // First provider
-                       this.getProviderCountry().compareTo(otherProvider.getProviderCountry()),
-                       // Next is name
-                       StringUtils.compare(this.getProviderName(), otherProvider.getProviderName()),
-                       // Last is dial prefix
-                       this.getProviderDialPrefix().compareTo(otherProvider.getProviderDialPrefix())
+                       // First provider country
+                       CountryUtils.compare(this.getProviderCountry(), provider.getProviderCountry()),
+                       // ... provider name
+                       StringUtils.compare(this.getProviderName(), provider.getProviderName()),
+                       // ... dial prefix
+                       SafeNumberUtils.compare(this.getProviderDialPrefix(), provider.getProviderDialPrefix()),
+                       // ... mail pattern
+                       StringUtils.compare(this.getProviderMailPattern(), provider.getProviderMailPattern())
                };
 
                // Check all values
diff --git a/src/org/mxchange/jphone/model/phonenumbers/mobileprovider/MobileProviders.java b/src/org/mxchange/jphone/model/phonenumbers/mobileprovider/MobileProviders.java
deleted file mode 100644 (file)
index 10164bd..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2017 - 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with targetMobileProvider program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jphone.model.phonenumbers.mobileprovider;
-
-import java.io.Serializable;
-import java.util.Objects;
-import org.mxchange.jcountry.model.data.Countries;
-
-/**
- * An utilities class for mobile providers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class MobileProviders implements Serializable {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 15_468_608_721_651L;
-
-       /**
-        * Copies all values from source mobile provider to this
-        * <p>
-        * @param sourceMobileProvider Source mobile provider
-        * @param targetMobileProvider Target mobile provider
-        */
-       public static void copyMobileProviderData (final MobileProvider sourceMobileProvider, final MobileProvider targetMobileProvider) {
-               // Parameter should not be null
-               if (null == sourceMobileProvider) {
-                       // Throw NPE
-                       throw new NullPointerException("sourceMobileProvider is null"); //NOI18N
-               } else if (null == targetMobileProvider) {
-                       // Throw NPE
-                       throw new NullPointerException("targetMobileProvider is null"); //NOI18N
-               } else if (Objects.equals(sourceMobileProvider, targetMobileProvider)) {
-                       // Is same mobile provider
-                       throw new IllegalArgumentException("Source and target mobile provider are the same."); //NOI18N
-               }
-
-               // Copy all values
-               Countries.copyCountryData(sourceMobileProvider.getProviderCountry(), targetMobileProvider.getProviderCountry());
-               targetMobileProvider.setProviderDialPrefix(sourceMobileProvider.getProviderDialPrefix());
-               targetMobileProvider.setProviderId(sourceMobileProvider.getProviderId());
-               targetMobileProvider.setProviderMailPattern(sourceMobileProvider.getProviderMailPattern());
-               targetMobileProvider.setProviderName(sourceMobileProvider.getProviderName());
-       }
-
-       /**
-        * Private constructor, because there is no need for an instance of
-        * targetMobileProvider class.
-        */
-       private MobileProviders () {
-       }
-
-}
diff --git a/src/org/mxchange/jphone/model/utils/FaxNumberUtils.java b/src/org/mxchange/jphone/model/utils/FaxNumberUtils.java
new file mode 100644 (file)
index 0000000..25b63f4
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2017 - 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.model.utils;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+
+/**
+ * An utilities class for fax numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class FaxNumberUtils implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 1_948_653_672_761L;
+
+       /**
+        * Copy all fields from source object to this
+        * <p>
+        * @param sourceNumber Source number object
+        * @param targetNumber Target number object
+        */
+       public static void copyFaxNumberData (final DialableFaxNumber sourceNumber, final DialableFaxNumber targetNumber) {
+               // Validate instance
+               if (null == sourceNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceNumber is null"); //NOI18N
+               } else if (null == targetNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("targetNumber is null"); //NOI18N
+               } else if (Objects.equals(sourceNumber, targetNumber)) {
+                       // Is exactly the same!
+                       throw new IllegalArgumentException("sourcerNumber and targetNumber are the same."); //NOI18N
+               }
+
+               // Copy all
+               targetNumber.setPhoneAreaCode(sourceNumber.getPhoneAreaCode());
+               targetNumber.setPhoneCountry(sourceNumber.getPhoneCountry());
+               targetNumber.setPhoneId(sourceNumber.getPhoneId());
+               targetNumber.setPhoneNumber(sourceNumber.getPhoneNumber());
+       }
+
+       /**
+        * Checks if both are the same
+        * <p>
+        * @param faxNumber   First fax number
+        * @param otherNumber Second fax number
+        * <p>
+        * @return Whether both are the same
+        */
+       public static boolean isSameFaxNumber (final DialableFaxNumber faxNumber, DialableFaxNumber otherNumber) {
+               // Test object equality first
+               if (Objects.equals(faxNumber, otherNumber)) {
+                       // Both the same object (null/null or same object)
+                       return true;
+               } else if (((null == faxNumber) && (otherNumber instanceof DialableFaxNumber)) || ((null == otherNumber) && (faxNumber instanceof DialableFaxNumber))) {
+                       // One is null the other not
+                       return false;
+               }
+               // Now compare deeper
+               final boolean sameCountry = Objects.equals(faxNumber.getPhoneCountry(), otherNumber.getPhoneCountry());
+               final boolean sameAreaCode = Objects.equals(faxNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode());
+               final boolean sameNumber = Objects.equals(faxNumber.getPhoneNumber(), otherNumber.getPhoneNumber());
+               // All are the same?
+               return sameCountry && sameAreaCode && sameNumber;
+       }
+
+       /**
+        * No constructor for utilities classes
+        */
+       private FaxNumberUtils () {
+       }
+
+}
diff --git a/src/org/mxchange/jphone/model/utils/LandLineNumberUtils.java b/src/org/mxchange/jphone/model/utils/LandLineNumberUtils.java
new file mode 100644 (file)
index 0000000..d7063ed
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2017 - 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with targetNumber program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.model.utils;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+
+/**
+ * An utilities class for land-line numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class LandLineNumberUtils implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 18_698_467_372_167_561L;
+
+       /**
+        * Copy all fields from source object to this
+        * <p>
+        * @param sourceNumber Source number object
+        * @param targetNumber Target number object
+        */
+       public static void copyLandLineNumberData (final DialableLandLineNumber sourceNumber, final DialableLandLineNumber targetNumber) {
+               // Validate instance
+               if (null == sourceNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceNumber is null"); //NOI18N
+               } else if (null == targetNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("targetNumber is null"); //NOI18N
+               } else if (Objects.equals(sourceNumber, targetNumber)) {
+                       // Is exactly the same!
+                       throw new IllegalArgumentException("sourcerNumber and targetNumber are the same."); //NOI18N
+               }
+
+               // Copy all
+               targetNumber.setPhoneAreaCode(sourceNumber.getPhoneAreaCode());
+               targetNumber.setPhoneCountry(sourceNumber.getPhoneCountry());
+               targetNumber.setPhoneId(sourceNumber.getPhoneId());
+               targetNumber.setPhoneNumber(sourceNumber.getPhoneNumber());
+       }
+
+       /**
+        * Checks if both are the same
+        * <p>
+        * @param landLineNumber First land-line number
+        * @param otherNumber    Second land-line number
+        * <p>
+        * @return Whether both are the same
+        */
+       public static boolean isSameLandLineNumber (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber otherNumber) {
+               // Test object equality first
+               if (Objects.equals(landLineNumber, otherNumber)) {
+                       // Both the same object (null/null or same object)
+                       return true;
+               } else if (((null == landLineNumber) && (otherNumber instanceof DialableLandLineNumber)) || ((null == otherNumber) && (landLineNumber instanceof DialableLandLineNumber))) {
+                       // One is null the other not
+                       return false;
+               }
+               // Now compare deeper
+               final boolean sameCountry = Objects.equals(landLineNumber.getPhoneCountry(), otherNumber.getPhoneCountry());
+               final boolean sameAreaCode = Objects.equals(landLineNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode());
+               final boolean sameNumber = Objects.equals(landLineNumber.getPhoneNumber(), otherNumber.getPhoneNumber());
+               // All are the same?
+               return sameCountry && sameAreaCode && sameNumber;
+       }
+
+       /**
+        * No constructor for utilities classes
+        */
+       private LandLineNumberUtils () {
+       }
+
+}
diff --git a/src/org/mxchange/jphone/model/utils/MobileNumberUtils.java b/src/org/mxchange/jphone/model/utils/MobileNumberUtils.java
new file mode 100644 (file)
index 0000000..805f0c1
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2017 - 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with targetNumber program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.model.utils;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+
+/**
+ * An utilities class for mobile numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class MobileNumberUtils implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 291_608_496_882_761L;
+
+       /**
+        * Copy all fields from source object to this
+        * <p>
+        * @param sourceNumber Source number object
+        * @param targetNumber Target number object
+        */
+       public static void copyMobileNumberData (final DialableMobileNumber sourceNumber, final DialableMobileNumber targetNumber) {
+               // Validate instance
+               if (null == sourceNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceNumber is null"); //NOI18N
+               } else if (null == targetNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("targetNumber is null"); //NOI18N
+               } else if (Objects.equals(sourceNumber, targetNumber)) {
+                       // Is exactly the same!
+                       throw new IllegalArgumentException("sourcerNumber and targetNumber are the same."); //NOI18N
+               }
+
+               // Copy all fields
+               targetNumber.setMobileProvider(sourceNumber.getMobileProvider());
+               targetNumber.setMobileId(sourceNumber.getMobileId());
+               targetNumber.setMobileNumber(sourceNumber.getMobileNumber());
+       }
+
+       /**
+        * Checks if both are the same
+        * <p>
+        * @param mobileNumber Mobile number 1
+        * @param otherNumber  Mobile number 2
+        * <p>
+        * @return Whether both are the same number
+        * <p>
+        * @throws NullPointerException If both instances are null
+        */
+       public static boolean isSameMobileNumber (final DialableMobileNumber mobileNumber, final DialableMobileNumber otherNumber) {
+               // Test object equality first
+               if (Objects.equals(mobileNumber, otherNumber)) {
+                       // Both the same object (null/null or same object)
+                       return true;
+               } else if (((null == mobileNumber) && (otherNumber instanceof DialableMobileNumber)) || ((null == otherNumber) && (mobileNumber instanceof DialableMobileNumber))) {
+                       // One is null the other not
+                       return false;
+               } else if (null == mobileNumber && null == otherNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("Both mobileNumber and otherNumber are null"); //NOI18N
+               }
+
+               // Now compare deeper
+               final boolean sameProvider = Objects.equals(mobileNumber.getMobileProvider(), otherNumber.getMobileProvider());
+               final boolean sameNumber = Objects.equals(mobileNumber.getMobileNumber(), otherNumber.getMobileNumber());
+
+               // All are the same?
+               return sameProvider && sameNumber;
+       }
+
+       /**
+        * No constructor for utilities classes
+        */
+       private MobileNumberUtils () {
+       }
+
+}
diff --git a/src/org/mxchange/jphone/model/utils/MobileProviderUtils.java b/src/org/mxchange/jphone/model/utils/MobileProviderUtils.java
new file mode 100644 (file)
index 0000000..c403a47
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2017 - 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with targetMobileProvider program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.model.utils;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.mxchange.jcountry.model.utils.CountryUtils;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
+
+/**
+ * An utilities class for mobile providers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class MobileProviderUtils implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_468_608_721_651L;
+
+       public static int compare (MobileProvider mobileProvider, MobileProvider mobileProvider0) {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       /**
+        * Copies all values from source mobile provider to this
+        * <p>
+        * @param sourceMobileProvider Source mobile provider
+        * @param targetMobileProvider Target mobile provider
+        */
+       public static void copyMobileProviderData (final MobileProvider sourceMobileProvider, final MobileProvider targetMobileProvider) {
+               // Parameter should not be null
+               if (null == sourceMobileProvider) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceMobileProvider is null"); //NOI18N
+               } else if (null == targetMobileProvider) {
+                       // Throw NPE
+                       throw new NullPointerException("targetMobileProvider is null"); //NOI18N
+               } else if (Objects.equals(sourceMobileProvider, targetMobileProvider)) {
+                       // Is same mobile provider
+                       throw new IllegalArgumentException("Source and target mobile provider are the same."); //NOI18N
+               }
+
+               // Copy all values
+               CountryUtils.copyCountryData(sourceMobileProvider.getProviderCountry(), targetMobileProvider.getProviderCountry());
+               targetMobileProvider.setProviderDialPrefix(sourceMobileProvider.getProviderDialPrefix());
+               targetMobileProvider.setProviderId(sourceMobileProvider.getProviderId());
+               targetMobileProvider.setProviderMailPattern(sourceMobileProvider.getProviderMailPattern());
+               targetMobileProvider.setProviderName(sourceMobileProvider.getProviderName());
+       }
+
+       /**
+        * Private constructor, because there is no need for an instance of
+        * targetMobileProvider class.
+        */
+       private MobileProviderUtils () {
+       }
+
+}