]> git.mxchange.org Git - jphone-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 14 Apr 2020 07:40:02 +0000 (09:40 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 14 Apr 2020 07:40:02 +0000 (09:40 +0200)
- DialableMobileNumber no longer depends on DialableNumber and provides now
  getter for mobileId and mobileNumber instead of phoneId and phoneNumber
- renamed copyAll() to copySomeFoo() for better accuracy
- moved isSameFooBar() to proper FooBars utilities class
- implemented java.lang.Comparable to have sorting possible e.g. in p:dataTable
  PrimeFaces tag
- always validate parameter in contructors and public/protected methods
- renamed phone_entry_created to fax_entry_created
- fooEntryUpdated is always not insertable, while fooEntryCreated is never updatable

Signed-off-by: Roland Häder <roland@mxchange.org>
15 files changed:
src/org/mxchange/jphone/exceptions/phone/PhoneNumberAlreadyLinkedException.java
src/org/mxchange/jphone/exceptions/phone/PhoneNumberNotLinkedException.java
src/org/mxchange/jphone/model/phonenumbers/fax/DialableFaxNumber.java
src/org/mxchange/jphone/model/phonenumbers/fax/FaxNumber.java
src/org/mxchange/jphone/model/phonenumbers/fax/FaxNumbers.java
src/org/mxchange/jphone/model/phonenumbers/landline/DialableLandLineNumber.java
src/org/mxchange/jphone/model/phonenumbers/landline/LandLineNumber.java
src/org/mxchange/jphone/model/phonenumbers/landline/LandLineNumbers.java
src/org/mxchange/jphone/model/phonenumbers/mobile/DialableMobileNumber.java
src/org/mxchange/jphone/model/phonenumbers/mobile/MobileNumber.java
src/org/mxchange/jphone/model/phonenumbers/mobile/MobileNumbers.java
src/org/mxchange/jphone/model/phonenumbers/mobileprovider/CellphoneProvider.java
src/org/mxchange/jphone/model/phonenumbers/mobileprovider/MobileProvider.java
src/org/mxchange/jphone/model/phonenumbers/mobileprovider/MobileProviders.java
src/org/mxchange/jphone/utils/PhoneUtils.java [deleted file]

index 589b38747684b8a73c2ebe8c7d047fafc739d694..7aea5a02b25a312b56771e58b2cc99d9911dd2a3 100644 (file)
@@ -35,7 +35,7 @@ public class PhoneNumberAlreadyLinkedException extends Exception {
        private static final long serialVersionUID = 18_964_581_681_985_598L;
 
        /**
-        * Counstructor with fax number
+        * Constructor with fax number
         * <p>
         * @param faxNumber Fax number
         */
@@ -45,7 +45,7 @@ public class PhoneNumberAlreadyLinkedException extends Exception {
        }
 
        /**
-               * Counstructor with landLine number
+        * Constructor with landLine number
         * <p>
         * @param landLineNumber Land-line number
         */
@@ -55,13 +55,13 @@ public class PhoneNumberAlreadyLinkedException extends Exception {
        }
 
        /**
-        * Counstructor with mobile number
+        * Constructor with mobile number
         * <p>
         * @param mobileNumber Mobile number
         */
        public PhoneNumberAlreadyLinkedException (final DialableMobileNumber mobileNumber) {
                // Call super constructor with message
-               super(MessageFormat.format("mobileNumber={0} with phoneId={1} cannot be linked, link target has already mobile number linked.", mobileNumber, mobileNumber.getPhoneId())); //NOI18N
+               super(MessageFormat.format("mobileNumber={0} with phoneId={1} cannot be linked, link target has already mobile number linked.", mobileNumber, mobileNumber.getMobileId())); //NOI18N
        }
 
 }
index 4552c18e01c1d4a3d92a661652196be1ca322288..dc8211cdb9f452b491a91a722efc8c78829070c0 100644 (file)
@@ -35,7 +35,7 @@ public class PhoneNumberNotLinkedException extends Exception {
        private static final long serialVersionUID = 18_964_581_681_985_599L;
 
        /**
-        * Counstructor with fax number
+        * Constructor with fax number
         * <p>
         * @param faxNumber Fax number
         */
@@ -45,7 +45,7 @@ public class PhoneNumberNotLinkedException extends Exception {
        }
 
        /**
-               * Counstructor with landLine number
+        * Constructor with landLine number
         * <p>
         * @param landLineNumber Land-line number
         */
@@ -55,13 +55,13 @@ public class PhoneNumberNotLinkedException extends Exception {
        }
 
        /**
-        * Counstructor with mobile number
+        * Constructor with mobile number
         * <p>
         * @param mobileNumber Mobile number
         */
        public PhoneNumberNotLinkedException (final DialableMobileNumber mobileNumber) {
                // Call super constructor with message
-               super(MessageFormat.format("mobileNumber={0} with phoneId={1} is not linked.", mobileNumber, mobileNumber.getPhoneId())); //NOI18N
+               super(MessageFormat.format("mobileNumber={0} with phoneId={1} is not linked.", mobileNumber, mobileNumber.getMobileId())); //NOI18N
        }
 
 }
index 61238c00682597b7b8237c65e780ed487311b86c..75d3e3b6a936939c8619c55cce61e661146d643b 100644 (file)
@@ -23,7 +23,7 @@ import org.mxchange.jphone.model.phonenumbers.DialableNumber;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-public interface DialableFaxNumber extends DialableNumber {
+public interface DialableFaxNumber extends Comparable<DialableFaxNumber>, DialableNumber {
 
        @Override
        boolean equals (final Object object);
index ff9d400d2cca152f416a72147e42f4d20e224be9..d112496efc20943746c79b658306d103520bfdcb 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jphone.model.phonenumbers.fax;
 
+import java.text.MessageFormat;
 import java.util.Date;
 import java.util.Objects;
 import javax.persistence.Basic;
@@ -33,6 +34,7 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
+import org.mxchange.jcoreutils.Comparables;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jcountry.model.data.CountryData;
 
@@ -45,8 +47,7 @@ import org.mxchange.jcountry.model.data.CountryData;
 @Table (name = "fax_numbers")
 @NamedQueries (
                {
-                       @NamedQuery (name = "AllFaxNumbers", query = "SELECT f FROM fax_numbers AS f ORDER BY f.phoneId ASC"),
-                       @NamedQuery (name = "SearchFaxNumberId", query = "SELECT f FROM fax_numbers AS f WHERE f.phoneId = :faxNumberId")
+                       @NamedQuery (name = "AllFaxNumbers", query = "SELECT f FROM fax_numbers AS f ORDER BY f.phoneId ASC")
                }
 )
 @SuppressWarnings ("PersistenceUnitPresent")
@@ -84,7 +85,7 @@ public class FaxNumber implements DialableFaxNumber {
         * Timestamp when this entry has been created
         */
        @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "phone_entry_updated", updatable = false)
+       @Column (name = "fax_entry_updated", insertable = false)
        private Date phoneEntryUpdated;
 
        /**
@@ -111,20 +112,72 @@ public class FaxNumber implements DialableFaxNumber {
        /**
         * Constructor with country, area code and number
         * <p>
-        * @param faxCountry Country instance
+        * @param faxCountry  Country instance
         * @param faxAreaCode Area code (without leading zeros)
-        * @param faxNumber Fax number (without area code and leading zero)
+        * @param faxNumber   Fax number (without area code and leading zero)
         */
        public FaxNumber (final Country faxCountry, final Integer faxAreaCode, final Long faxNumber) {
-               // Call default constructor
+               // Invoke default constructor
                this();
 
+               // Are all parameter set?
+               if (null == faxAreaCode) {
+                       // Throw NPE
+                       throw new NullPointerException("faxAreaCode is null"); //NOI18N
+               } else if (faxAreaCode < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("faxAreaCode={0} is not valid.", faxAreaCode)); //NOI18N
+               } else if (null == faxCountry) {
+                       // Throw NPE
+                       throw new NullPointerException("faxCountry is null"); //NOI18N
+               } else if (null == faxCountry.getCountryId()) {
+                       // Throw NPE again
+                       throw new NullPointerException("faxCountry.countryId is null"); //NOI18N
+               } else if (faxCountry.getCountryId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("faxCountry.countryId={0} is not valid", faxCountry.getCountryId())); //NOI18N
+               } else if (null == faxNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("faxNumber is null"); //NOI18N
+               } else if (faxNumber < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber={0} is not valid.", faxNumber)); //NOI18N
+               }
+
                // Set all values
                this.faxCountry = faxCountry;
                this.faxAreaCode = faxAreaCode;
                this.phoneNumber = faxNumber;
        }
 
+       @Override
+       public int compareTo (final DialableFaxNumber otherNumber) {
+               // Is the parameter given?
+               if (null == otherNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("otherNumber is null"); //NOI18N
+               } else if (otherNumber.equals(this)) {
+                       // Same object
+                       return 0;
+               }
+
+               // Init comparisons
+               final int[] comparators = {
+                       // First country
+                       this.getPhoneCountry().compareTo(otherNumber.getPhoneCountry()),
+                       // Next area code
+                       this.getPhoneAreaCode().compareTo(otherNumber.getPhoneAreaCode()),
+                       // Last number
+                       this.getPhoneNumber().compareTo(otherNumber.getPhoneNumber())
+               };
+
+               // Check all values
+               final int comparison = Comparables.checkAll(comparators);
+
+               // Return value
+               return comparison;
+       }
+
        @Override
        public boolean equals (final Object object) {
                if (null == object) {
@@ -133,15 +186,15 @@ public class FaxNumber implements DialableFaxNumber {
                        return false;
                }
 
-               final DialableFaxNumber other = (DialableFaxNumber) object;
+               final DialableFaxNumber dialableFaxNumber = (DialableFaxNumber) object;
 
-               if (!Objects.equals(this.getPhoneNumber(), other.getPhoneNumber())) {
+               if (!Objects.equals(this.getPhoneNumber(), dialableFaxNumber.getPhoneNumber())) {
                        return false;
-               } else if (!Objects.equals(this.getPhoneId(), other.getPhoneId())) {
+               } else if (!Objects.equals(this.getPhoneId(), dialableFaxNumber.getPhoneId())) {
                        return false;
-               } else if (!Objects.equals(this.getPhoneAreaCode(), other.getPhoneAreaCode())) {
+               } else if (!Objects.equals(this.getPhoneAreaCode(), dialableFaxNumber.getPhoneAreaCode())) {
                        return false;
-               } else if (!Objects.equals(this.getPhoneCountry(), other.getPhoneCountry())) {
+               } else if (!Objects.equals(this.getPhoneCountry(), dialableFaxNumber.getPhoneCountry())) {
                        return false;
                }
 
index 487d4c30f401aee7baabdb588b1ffd4634588cf2..9ffdac4bd4834cfba359774f385534056cff1e85 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.jphone.model.phonenumbers.fax;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * An utilities class for fax numbers
@@ -36,7 +37,7 @@ public class FaxNumbers implements Serializable {
         * @param sourceNumber Source number object
         * @param targetNumber Target number object
         */
-       public static void copyAll (final DialableFaxNumber sourceNumber, final DialableFaxNumber targetNumber) {
+       public static void copyFaxNumber (final DialableFaxNumber sourceNumber, final DialableFaxNumber targetNumber) {
                // Validate instance
                if (null == sourceNumber) {
                        // Throw NPE
@@ -54,6 +55,31 @@ public class FaxNumbers implements Serializable {
                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
         */
index d24ffb215ad0bc9084823d2ec47d43ad304f67ff..013789e8f4565eb3a3530370e2ac68b7d35fe228 100644 (file)
@@ -23,7 +23,7 @@ import org.mxchange.jphone.model.phonenumbers.DialableNumber;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-public interface DialableLandLineNumber extends DialableNumber {
+public interface DialableLandLineNumber extends Comparable<DialableLandLineNumber>, DialableNumber {
 
        @Override
        boolean equals (final Object object);
index 71b825fb9912a6ca26c2d7113da6b59d7da6e653..d7f601e5b4eaccb34da7468f91c6a66580448137 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jphone.model.phonenumbers.landline;
 
+import java.text.MessageFormat;
 import java.util.Date;
 import java.util.Objects;
 import javax.persistence.Basic;
@@ -33,6 +34,7 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
+import org.mxchange.jcoreutils.Comparables;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jcountry.model.data.CountryData;
 
@@ -45,8 +47,7 @@ import org.mxchange.jcountry.model.data.CountryData;
 @Table (name = "landline_numbers")
 @NamedQueries (
                {
-                       @NamedQuery (name = "AllLandLineNumbers", query = "SELECT p FROM landline_numbers AS p ORDER BY p.phoneId ASC"),
-                       @NamedQuery (name = "SearchLandLineNumberId", query = "SELECT p FROM landline_numbers AS p WHERE p.phoneId = :landLineNumberId")
+                       @NamedQuery (name = "AllLandLineNumbers", query = "SELECT p FROM landline_numbers AS p ORDER BY p.phoneId ASC")
                }
 )
 @SuppressWarnings ("PersistenceUnitPresent")
@@ -84,7 +85,7 @@ public class LandLineNumber implements DialableLandLineNumber {
         * Timestamp when this entry has been created
         */
        @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "landline_entry_updated", updatable = false)
+       @Column (name = "landline_entry_updated", insertable = false)
        private Date phoneEntryUpdated;
 
        /**
@@ -111,18 +112,70 @@ public class LandLineNumber implements DialableLandLineNumber {
        /**
         * Constructor with country instance, area code and number
         * <p>
-        * @param phoneCountry Country instance
-        * @param phoneAreaCode Phone area code
-        * @param phoneNumber Phone number
+        * @param landLineCountry  An instance of a Country class
+        * @param landLineAreaCode Land-line area code
+        * @param landLineNumber   Land-line number
         */
-       public LandLineNumber (final Country phoneCountry, final Integer phoneAreaCode, final Long phoneNumber) {
-               // Call default constructor
+       public LandLineNumber (final Country landLineCountry, final Integer landLineAreaCode, final Long landLineNumber) {
+               // Invoke default constructor
                this();
 
+               // Are all parameter set?
+               if (null == landLineAreaCode) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineAreaCode is null"); //NOI18N
+               } else if (landLineAreaCode < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("landLineAreaCode={0} is not valid.", landLineAreaCode)); //NOI18N
+               } else if (null == landLineCountry) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineCountry is null"); //NOI18N
+               } else if (null == landLineCountry.getCountryId()) {
+                       // Throw NPE again
+                       throw new NullPointerException("landLineCountry.countryId is null"); //NOI18N
+               } else if (landLineCountry.getCountryId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("landLineCountry.countryId={0} is not valid", landLineCountry.getCountryId())); //NOI18N
+               } else if (null == landLineNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineNumber is null"); //NOI18N
+               } else if (landLineNumber < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber={0} is not valid.", landLineNumber)); //NOI18N
+               }
+
                // Set all values
-               this.phoneCountry = phoneCountry;
-               this.phoneAreaCode = phoneAreaCode;
-               this.phoneNumber = phoneNumber;
+               this.phoneCountry = landLineCountry;
+               this.phoneAreaCode = landLineAreaCode;
+               this.phoneNumber = landLineNumber;
+       }
+
+       @Override
+       public int compareTo (final DialableLandLineNumber otherNumber) {
+               // Is the parameter given?
+               if (null == otherNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("otherNumber is null"); //NOI18N
+               } else if (otherNumber.equals(this)) {
+                       // Same object
+                       return 0;
+               }
+
+               // Init comparisons
+               final int[] comparators = {
+                       // First country
+                       this.getPhoneCountry().compareTo(otherNumber.getPhoneCountry()),
+                       // Next area code
+                       this.getPhoneAreaCode().compareTo(otherNumber.getPhoneAreaCode()),
+                       // Last number
+                       this.getPhoneNumber().compareTo(otherNumber.getPhoneNumber())
+               };
+
+               // Check all values
+               final int comparison = Comparables.checkAll(comparators);
+
+               // Return value
+               return comparison;
        }
 
        @Override
@@ -133,15 +186,15 @@ public class LandLineNumber implements DialableLandLineNumber {
                        return false;
                }
 
-               final DialableLandLineNumber other = (DialableLandLineNumber) object;
+               final DialableLandLineNumber landLineNumber = (DialableLandLineNumber) object;
 
-               if (!Objects.equals(this.getPhoneId(), other.getPhoneId())) {
+               if (!Objects.equals(this.getPhoneId(), landLineNumber.getPhoneId())) {
                        return false;
-               } else if (!Objects.equals(this.getPhoneNumber(), other.getPhoneNumber())) {
+               } else if (!Objects.equals(this.getPhoneNumber(), landLineNumber.getPhoneNumber())) {
                        return false;
-               } else if (!Objects.equals(this.getPhoneAreaCode(), other.getPhoneAreaCode())) {
+               } else if (!Objects.equals(this.getPhoneAreaCode(), landLineNumber.getPhoneAreaCode())) {
                        return false;
-               } else if (!Objects.equals(this.getPhoneCountry(), other.getPhoneCountry())) {
+               } else if (!Objects.equals(this.getPhoneCountry(), landLineNumber.getPhoneCountry())) {
                        return false;
                }
 
index 2944be96759bc695af272d1229f97e869832dda3..59c3fd75c0a85ad31f9c77df747847c128ab1ff4 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.jphone.model.phonenumbers.landline;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * An utilities class for land-line numbers
@@ -36,7 +37,7 @@ public class LandLineNumbers implements Serializable {
         * @param sourceNumber Source number object
         * @param targetNumber Target number object
         */
-       public static void copyAll (final DialableLandLineNumber sourceNumber, final DialableLandLineNumber targetNumber) {
+       public static void copyLandLineNumber (final DialableLandLineNumber sourceNumber, final DialableLandLineNumber targetNumber) {
                // Validate instance
                if (null == sourceNumber) {
                        // Throw NPE
@@ -54,6 +55,31 @@ public class LandLineNumbers implements Serializable {
                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
         */
index b248932a311c1b4e624f52523fb1df17c39d7774..2ea217761c076c3f2454acecdcb6b7708d3807a2 100644 (file)
  */
 package org.mxchange.jphone.model.phonenumbers.mobile;
 
+import java.io.Serializable;
+import java.util.Date;
 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
-import org.mxchange.jphone.model.phonenumbers.DialableNumber;
 
 /**
  * A POJO for dialable mobile numbers with carriers.
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-public interface DialableMobileNumber extends DialableNumber {
+public interface DialableMobileNumber extends Comparable<DialableMobileNumber>, Serializable {
 
        /**
         * Getter for mobile provider
@@ -40,6 +41,62 @@ public interface DialableMobileNumber extends DialableNumber {
         */
        void setMobileProvider (final MobileProvider mobileProvider);
 
+       /**
+        * Getter for id number
+        * <p>
+        * @return Id number
+        */
+       Long getMobileId ();
+
+       /**
+        * Setter for id number
+        * <p>
+        * @param mobileId Id number
+        */
+       void setMobileId (final Long mobileId);
+
+       /**
+        * Getter for mobile number without prefix
+        * <p>
+        * @return Mobile number without prefix
+        */
+       Long getMobileNumber ();
+
+       /**
+        * Setter for mobile number without prefix
+        * <p>
+        * @param mobileNumber Mobile number without prefix
+        */
+       void setMobileNumber (final Long mobileNumber);
+
+       /**
+        * Getter for timestamp when this entry has been created
+        * <p>
+        * @return Timestamp when this entry has been created
+        */
+       Date getMobileEntryCreated ();
+
+       /**
+        * Setter for timestamp when this entry has been created
+        * <p>
+        * @param mobileEntryCreated Timestamp when this entry has been created
+        */
+       void setMobileEntryCreated (final Date mobileEntryCreated);
+
+       /**
+        * Getter for timestamp when this entry has been updated
+        * <p>
+        * @return Timestamp when this entry has been updated
+        */
+       Date getMobileEntryUpdated ();
+
+       /**
+        * Setter for timestamp when this entry has been updated
+        * <p>
+        * @param mobileEntryUpdated Timestamp when this entry has been updated
+        */
+       void setMobileEntryUpdated (final Date mobileEntryUpdated);
+
        @Override
        boolean equals (final Object object);
 
index 45a7a45f8d30f94d7bf8ca5a5b2cbf94b2f515ce..b1ee3aaf54b19cd40072a7f7d88e5023115cd236 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jphone.model.phonenumbers.mobile;
 
+import java.text.MessageFormat;
 import java.util.Date;
 import java.util.Objects;
 import javax.persistence.Basic;
@@ -33,12 +34,12 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
-import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jcoreutils.Comparables;
 import org.mxchange.jphone.model.phonenumbers.mobileprovider.CellphoneProvider;
 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
 
 /**
- * A POJO for dialable cellphone numbers
+ * A POJO for dialable mobile numbers
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
@@ -46,8 +47,7 @@ import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
 @Table (name = "mobile_numbers")
 @NamedQueries (
                {
-                       @NamedQuery (name = "AllMobileNumbers", query = "SELECT c FROM mobile_numbers AS c ORDER BY c.phoneId ASC"),
-                       @NamedQuery (name = "SearchMobileNumberId", query = "SELECT c FROM mobile_numbers AS c WHERE c.phoneId = :mobileNumberId")
+                       @NamedQuery (name = "AllMobileNumbers", query = "SELECT m FROM mobile_numbers AS m ORDER BY m.mobileId ASC")
                }
 )
 @SuppressWarnings ("PersistenceUnitPresent")
@@ -59,27 +59,20 @@ public class MobileNumber implements DialableMobileNumber {
        @Transient
        private static final long serialVersionUID = 13_859_879_482_106L;
 
-       /**
-        * Connection to table "mobile_provider" (for dial prefix and more data)
-        */
-       @JoinColumn (name = "mobile_provider_id", nullable = false)
-       @OneToOne (targetEntity = CellphoneProvider.class, cascade = CascadeType.REFRESH, optional = false)
-       private MobileProvider mobileProvider;
-
        /**
         * Timestamp when this entry has been created
         */
        @Basic (optional = false)
        @Temporal (TemporalType.TIMESTAMP)
        @Column (name = "mobile_entry_created", nullable = false, updatable = false)
-       private Date phoneEntryCreated;
+       private Date mobileEntryCreated;
 
        /**
         * Timestamp when this entry has been created
         */
        @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "mobile_entry_updated", updatable = false)
-       private Date phoneEntryUpdated;
+       @Column (name = "mobile_entry_updated", insertable = false)
+       private Date mobileEntryUpdated;
 
        /**
         * Id number
@@ -87,14 +80,21 @@ public class MobileNumber implements DialableMobileNumber {
        @Id
        @GeneratedValue (strategy = GenerationType.IDENTITY)
        @Column (name = "mobile_id", nullable = false, updatable = false)
-       private Long phoneId;
+       private Long mobileId;
 
        /**
         * Number without prefix to dial
         */
        @Basic (optional = false)
        @Column (name = "mobile_number", nullable = false)
-       private Long phoneNumber;
+       private Long mobileNumber;
+
+       /**
+        * Connection to table "mobile_provider" (for dial prefix and more data)
+        */
+       @JoinColumn (name = "mobile_provider_id", nullable = false)
+       @OneToOne (targetEntity = CellphoneProvider.class, cascade = CascadeType.REFRESH, optional = false)
+       private MobileProvider mobileProvider;
 
        /**
         * Default constructor
@@ -103,18 +103,62 @@ public class MobileNumber implements DialableMobileNumber {
        }
 
        /**
-        * Constructor with cellphone provider and number
+        * Constructor with mobile provider and number
         * <p>
-        * @param mobileProvider Mobile provider
-        * @param mobileNumber Mobile number
+        * @param mobileProvider An instance of a MobileProvider class
+        * @param mobileNumber   Mobile calling number
         */
        public MobileNumber (final MobileProvider mobileProvider, final Long mobileNumber) {
-               // Call default constructor
+               // Invoke default constructor
                this();
 
+               // Are all parameter set?
+               if (null == mobileNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileNumber is null"); //NOI18N
+               } else if (mobileNumber < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber={0} is not valid.", mobileNumber)); //NOI18N
+               } else if (null == mobileProvider) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileProvider is null"); //NOI18N
+               } else if (mobileProvider.getProviderId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileProvider.providerId is null"); //NOI18N
+               } else if (mobileProvider.getProviderId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerId={0} is not valid", mobileProvider.getProviderId())); //NOI18N
+               }
+
                // Set all values
                this.mobileProvider = mobileProvider;
-               this.phoneNumber = mobileNumber;
+               this.mobileNumber = mobileNumber;
+       }
+
+       @Override
+       public int compareTo (final DialableMobileNumber otherNumber) {
+               // Is the parameter given?
+               if (null == otherNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("otherNumber is null"); //NOI18N
+               } else if (otherNumber.equals(this)) {
+                       // Same object
+                       return 0;
+               }
+
+               // Init comparisons
+               final int[] comparators = {
+                       // First compare provider
+                       this.getMobileProvider().compareTo(otherNumber.getMobileProvider()),
+                       // Last number
+                       this.getMobileNumber().compareTo(otherNumber.getMobileNumber())
+               };
+
+               // Check all values
+               final int comparison = Comparables.checkAll(comparators);
+
+               // Return value
+               return comparison;
        }
 
        @Override
@@ -125,13 +169,13 @@ public class MobileNumber implements DialableMobileNumber {
                        return false;
                }
 
-               final DialableMobileNumber other = (DialableMobileNumber) object;
+               final DialableMobileNumber dialableMobileNumber = (DialableMobileNumber) object;
 
-               if (!Objects.equals(this.getPhoneId(), other.getPhoneId())) {
+               if (!Objects.equals(this.getMobileId(), dialableMobileNumber.getMobileId())) {
                        return false;
-               } else if (!Objects.equals(this.getMobileProvider(), other.getMobileProvider())) {
+               } else if (!Objects.equals(this.getMobileProvider(), dialableMobileNumber.getMobileProvider())) {
                        return false;
-               } else if (!Objects.equals(this.getPhoneNumber(), other.getPhoneNumber())) {
+               } else if (!Objects.equals(this.getMobileNumber(), dialableMobileNumber.getMobileNumber())) {
                        return false;
                }
 
@@ -139,90 +183,66 @@ public class MobileNumber implements DialableMobileNumber {
        }
 
        @Override
-       public MobileProvider getMobileProvider () {
-               return this.mobileProvider;
-       }
-
-       @Override
-       public void setMobileProvider (final MobileProvider mobileProvider) {
-               this.mobileProvider = mobileProvider;
-       }
-
-       @Override
-       @Deprecated
-       public Integer getPhoneAreaCode () {
-               throw new UnsupportedOperationException("Mobile numbers don't have area codes. Please fix your code."); //NOI18N
-       }
-
-       @Override
-       @Deprecated
-       public void setPhoneAreaCode (final Integer phoneAreaCode) {
-               throw new UnsupportedOperationException("Mobile numbers don't have area codes. Please fix your code."); //NOI18N
-       }
-
-       @Override
-       @Deprecated
-       public Country getPhoneCountry () {
-               throw new UnsupportedOperationException("The country code is provided by MobileProvider."); //To change body of generated methods, choose Tools | Templates.
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getMobileEntryCreated () {
+               return this.mobileEntryCreated;
        }
 
        @Override
-       @Deprecated
-       public void setPhoneCountry (final Country country) {
-               throw new UnsupportedOperationException("The country code is provided by MobileProvider."); //To change body of generated methods, choose Tools | Templates.
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setMobileEntryCreated (final Date mobileEntryCreated) {
+               this.mobileEntryCreated = mobileEntryCreated;
        }
 
        @Override
        @SuppressWarnings ("ReturnOfDateField")
-       public Date getPhoneEntryCreated () {
-               return this.phoneEntryCreated;
+       public Date getMobileEntryUpdated () {
+               return this.mobileEntryUpdated;
        }
 
        @Override
        @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setPhoneEntryCreated (final Date phoneEntryCreated) {
-               this.phoneEntryCreated = phoneEntryCreated;
+       public void setMobileEntryUpdated (final Date mobileEntryUpdated) {
+               this.mobileEntryUpdated = mobileEntryUpdated;
        }
 
        @Override
-       @SuppressWarnings ("ReturnOfDateField")
-       public Date getPhoneEntryUpdated () {
-               return this.phoneEntryUpdated;
+       public Long getMobileId () {
+               return this.mobileId;
        }
 
        @Override
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setPhoneEntryUpdated (final Date phoneEntryUpdated) {
-               this.phoneEntryUpdated = phoneEntryUpdated;
+       public void setMobileId (final Long mobileId) {
+               this.mobileId = mobileId;
        }
 
        @Override
-       public Long getPhoneId () {
-               return this.phoneId;
+       public Long getMobileNumber () {
+               return this.mobileNumber;
        }
 
        @Override
-       public void setPhoneId (final Long phoneId) {
-               this.phoneId = phoneId;
+       public void setMobileNumber (final Long mobileNumber) {
+               this.mobileNumber = mobileNumber;
        }
 
        @Override
-       public Long getPhoneNumber () {
-               return this.phoneNumber;
+       public MobileProvider getMobileProvider () {
+               return this.mobileProvider;
        }
 
        @Override
-       public void setPhoneNumber (final Long phoneNumber) {
-               this.phoneNumber = phoneNumber;
+       public void setMobileProvider (final MobileProvider mobileProvider) {
+               this.mobileProvider = mobileProvider;
        }
 
        @Override
        public int hashCode () {
                int hash = 5;
 
-               hash = 97 * hash + Objects.hashCode(this.getPhoneId());
+               hash = 97 * hash + Objects.hashCode(this.getMobileId());
                hash = 97 * hash + Objects.hashCode(this.getMobileProvider());
-               hash = 97 * hash + Objects.hashCode(this.getPhoneNumber());
+               hash = 97 * hash + Objects.hashCode(this.getMobileNumber());
 
                return hash;
        }
index 1dab6545bfc24883f46d4c5af4e16f46a57b9f5d..37764bb4bb06ef5ad474c677a4307380272e73d6 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.jphone.model.phonenumbers.mobile;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * An utilities class for mobile numbers
@@ -36,7 +37,7 @@ public class MobileNumbers implements Serializable {
         * @param sourceNumber Source number object
         * @param targetNumber Target number object
         */
-       public static void copyAll (final DialableMobileNumber sourceNumber, final DialableMobileNumber targetNumber) {
+       public static void copyMobileNumber (final DialableMobileNumber sourceNumber, final DialableMobileNumber targetNumber) {
                // Validate instance
                if (null == sourceNumber) {
                        // Throw NPE
@@ -48,9 +49,33 @@ public class MobileNumbers implements Serializable {
 
                // Copy all fields
                targetNumber.setMobileProvider(sourceNumber.getMobileProvider());
-               targetNumber.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated());
-               targetNumber.setPhoneId(sourceNumber.getPhoneId());
-               targetNumber.setPhoneNumber(sourceNumber.getPhoneNumber());
+               targetNumber.setMobileEntryCreated(sourceNumber.getMobileEntryCreated());
+               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;
        }
 
        /**
index cd8f6cbd2f91e23486bbb4862bbf463a86fe48ee..5b2c9760f81381f7f0ab5bbe290a605bba476052 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jphone.model.phonenumbers.mobileprovider;
 
+import java.text.MessageFormat;
 import java.util.Date;
 import java.util.Objects;
 import javax.persistence.Basic;
@@ -33,11 +34,13 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
+import org.apache.commons.lang3.StringUtils;
+import org.mxchange.jcoreutils.Comparables;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jcountry.model.data.CountryData;
 
 /**
- * A POJO for cellphone providers
+ * A POJO for mobile providers
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
@@ -109,13 +112,43 @@ public class CellphoneProvider implements MobileProvider {
         * <p>
         * @param providerDialPrefix  Dial prefix
         * @param providerName        Name
-        * @param providerCountry     Country
+        * @param providerCountry     An instance of a Country class
         * @param providerMailPattern Pattern for email
         */
        public CellphoneProvider (final Long providerDialPrefix, final String providerName, final Country providerCountry, final String providerMailPattern) {
-               // Call default constructor
+               // Invoke default constructor
                this();
 
+               // Are all parameter set?
+               if (null == providerDialPrefix) {
+                       // Throw NPE
+                       throw new NullPointerException("providerDialPrefix is null"); //NOI18N
+               } else if (providerDialPrefix < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("providerDialPrefix={0} is not valid.", providerDialPrefix)); //NOI18N
+               } else if (null == providerName) {
+                       // Throw NPE
+                       throw new NullPointerException("providerName is null"); //NOI18N
+               } else if (providerName.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("providerName is empty"); //NOI18N
+               } else if (null == providerCountry) {
+                       // Throw NPE
+                       throw new NullPointerException("providerCountry is null"); //NOI18N
+               } else if (null == providerCountry.getCountryId()) {
+                       // Throw NPE again
+                       throw new NullPointerException("providerCountry.countryId is null"); //NOI18N
+               } else if (providerCountry.getCountryId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("providerCountry.countryId={0} is not valid", providerCountry.getCountryId())); //NOI18N
+               } else if (null == providerMailPattern) {
+                       // Throw NPE
+                       throw new NullPointerException("providerMailPattern is null"); //NOI18N
+               } else if (providerMailPattern.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("providerMailPattern is empty"); //NOI18N
+               }
+
                // Set all values
                this.providerDialPrefix = providerDialPrefix;
                this.providerName = providerName;
@@ -123,6 +156,34 @@ public class CellphoneProvider implements MobileProvider {
                this.providerMailPattern = providerMailPattern;
        }
 
+       @Override
+       public int compareTo (final MobileProvider otherProvider) {
+               // Is the parameter given?
+               if (null == otherProvider) {
+                       // Throw NPE
+                       throw new NullPointerException("otherProvider is null"); //NOI18N
+               } else if (otherProvider.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())
+               };
+
+               // Check all values
+               final int comparison = Comparables.checkAll(comparators);
+
+               // Return value
+               return comparison;
+       }
+
        @Override
        public boolean equals (final Object object) {
                if (null == object) {
@@ -131,28 +192,19 @@ public class CellphoneProvider implements MobileProvider {
                        return false;
                }
 
-               final MobileProvider other = (MobileProvider) object;
+               final MobileProvider mobileProvider = (MobileProvider) object;
 
-               if (!Objects.equals(this.getProviderDialPrefix(), other.getProviderDialPrefix())) {
+               if (!Objects.equals(this.getProviderDialPrefix(), mobileProvider.getProviderDialPrefix())) {
                        return false;
-               } else if (!Objects.equals(this.getProviderName(), other.getProviderName())) {
+               } else if (!Objects.equals(this.getProviderName(), mobileProvider.getProviderName())) {
                        return false;
-               } else if (!Objects.equals(this.getProviderCountry(), other.getProviderCountry())) {
+               } else if (!Objects.equals(this.getProviderCountry(), mobileProvider.getProviderCountry())) {
                        return false;
                }
 
                return true;
        }
 
-       @Override
-       public int hashCode () {
-               int hash = 7;
-               hash = 19 * hash + Objects.hashCode(this.getProviderDialPrefix());
-               hash = 19 * hash + Objects.hashCode(this.getProviderName());
-               hash = 19 * hash + Objects.hashCode(this.getProviderCountry());
-               return hash;
-       }
-
        @Override
        public Country getProviderCountry () {
                return this.providerCountry;
@@ -195,6 +247,16 @@ public class CellphoneProvider implements MobileProvider {
                this.providerId = providerId;
        }
 
+       @Override
+       public String getProviderMailPattern () {
+               return this.providerMailPattern;
+       }
+
+       @Override
+       public void setProviderMailPattern (final String providerMailPattern) {
+               this.providerMailPattern = providerMailPattern;
+       }
+
        @Override
        public String getProviderName () {
                return this.providerName;
@@ -206,13 +268,14 @@ public class CellphoneProvider implements MobileProvider {
        }
 
        @Override
-       public String getProviderMailPattern () {
-               return this.providerMailPattern;
-       }
+       public int hashCode () {
+               int hash = 7;
 
-       @Override
-       public void setProviderMailPattern (final String providerMailPattern) {
-               this.providerMailPattern = providerMailPattern;
+               hash = 19 * hash + Objects.hashCode(this.getProviderDialPrefix());
+               hash = 19 * hash + Objects.hashCode(this.getProviderName());
+               hash = 19 * hash + Objects.hashCode(this.getProviderCountry());
+
+               return hash;
        }
 
 }
index e96371f307ef9fc27578141581b3941f53bdae67..f7c7127371a185b12d79e75da1441e4ccc556f3e 100644 (file)
@@ -25,7 +25,7 @@ import org.mxchange.jcountry.model.data.Country;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-public interface MobileProvider extends Serializable {
+public interface MobileProvider extends Comparable<MobileProvider>, Serializable {
 
        /**
         * Getter for id number
index 76f66aa016180be2695b9622878c27ebba606173..5c645affdd9d889f87914277da00f0fab5b455fd 100644 (file)
@@ -38,7 +38,7 @@ public class MobileProviders implements Serializable {
         * @param sourceMobileProvider Source mobile provider
         * @param targetMobileProvider Target mobile provider
         */
-       public static void copyAll (final MobileProvider sourceMobileProvider, final MobileProvider targetMobileProvider) {
+       public static void copyMobileProvider (final MobileProvider sourceMobileProvider, final MobileProvider targetMobileProvider) {
                // Parameter should not be null
                if (null == sourceMobileProvider) {
                        // Throw NPE
diff --git a/src/org/mxchange/jphone/utils/PhoneUtils.java b/src/org/mxchange/jphone/utils/PhoneUtils.java
deleted file mode 100644 (file)
index 1e28f22..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2016 - 2020 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.utils;
-
-import java.io.Serializable;
-import java.util.Objects;
-import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
-
-/**
- *
- * @author Roland Häder<roland@mxchange.org>
- */
-public class PhoneUtils implements Serializable {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 183_598_328_176_450L;
-
-       /**
-        * 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
-               @SuppressWarnings ("null")
-               boolean sameCountry = Objects.equals(faxNumber.getPhoneCountry(), otherNumber.getPhoneCountry());
-               boolean sameAreaCode = Objects.equals(faxNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode());
-               boolean sameNumber = Objects.equals(faxNumber.getPhoneNumber(), otherNumber.getPhoneNumber());
-
-               // All are the same?
-               return (sameCountry && sameAreaCode && sameNumber);
-       }
-
-       /**
-        * 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
-               @SuppressWarnings ("null")
-               boolean sameCountry = Objects.equals(landLineNumber.getPhoneCountry(), otherNumber.getPhoneCountry());
-               boolean sameAreaCode = Objects.equals(landLineNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode());
-               boolean sameNumber = Objects.equals(landLineNumber.getPhoneNumber(), otherNumber.getPhoneNumber());
-
-               // All are the same?
-               return (sameCountry && sameAreaCode && sameNumber);
-       }
-
-       /**
-        * 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
-               @SuppressWarnings ("null")
-               boolean sameProvider = Objects.equals(mobileNumber.getMobileProvider(), otherNumber.getMobileProvider());
-               boolean sameNumber = Objects.equals(mobileNumber.getPhoneNumber(), otherNumber.getPhoneNumber());
-
-               // All are the same?
-               return (sameProvider && sameNumber);
-       }
-
-       /**
-        * Private constructor for utility classes
-        */
-       private PhoneUtils () {
-       }
-
-}