]> git.mxchange.org Git - jphone-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 21 Jan 2023 18:04:44 +0000 (19:04 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 21 Jan 2023 18:04:44 +0000 (19:04 +0100)
- added missing compare() methods to utilities classes
- added primary key and mail address pattern to equals()/hashCode()

src/org/mxchange/jphone/model/phonenumbers/mobileprovider/CellphoneProvider.java
src/org/mxchange/jphone/model/utils/FaxNumberUtils.java
src/org/mxchange/jphone/model/utils/LandLineNumberUtils.java
src/org/mxchange/jphone/model/utils/MobileNumberUtils.java
src/org/mxchange/jphone/model/utils/MobileProviderUtils.java

index 8efb8f8897bd353eb65b0d589e7b9446e4a9b71d..da3a8f7e6926c7870a1e9da307e1e4f48347659b 100644 (file)
@@ -207,6 +207,10 @@ public class CellphoneProvider implements MobileProvider {
 
                if (!Objects.equals(this.getProviderDialPrefix(), mobileProvider.getProviderDialPrefix())) {
                        return false;
+               } else if (!Objects.equals(this.getProviderId(), mobileProvider.getProviderId())) {
+                       return false;
+               } else if (!Objects.equals(this.getProviderMailPattern(), mobileProvider.getProviderMailPattern())) {
+                       return false;
                } else if (!Objects.equals(this.getProviderName(), mobileProvider.getProviderName())) {
                        return false;
                } else if (!Objects.equals(this.getProviderCountry(), mobileProvider.getProviderCountry())) {
@@ -295,6 +299,8 @@ public class CellphoneProvider implements MobileProvider {
                int hash = 7;
 
                hash = 19 * hash + Objects.hashCode(this.getProviderDialPrefix());
+               hash = 19 * hash + Objects.hashCode(this.getProviderId());
+               hash = 19 * hash + Objects.hashCode(this.getProviderMailPattern());
                hash = 19 * hash + Objects.hashCode(this.getProviderName());
                hash = 19 * hash + Objects.hashCode(this.getProviderCountry());
 
index 8337de61006d45cf7ac52652a2461a78c6a71dba..21bc09511cf6d5de921ae81a58c2886046cab91a 100644 (file)
@@ -32,6 +32,31 @@ public class FaxNumberUtils implements Serializable {
         */
        private static final long serialVersionUID = 1_948_653_672_761L;
 
+       /**
+        * Compares two fax number instances with each other
+        * <p>
+        * @param faxNumber1 First instance of a DialableFaxNumber class
+        * @param faxNumber2 Second instance of a DialableFaxNumber class
+        * <p>
+        * @return Comparison value
+        */
+       public static int compare (final DialableFaxNumber faxNumber1, final DialableFaxNumber faxNumber2) {
+               // Check equality, then at least first must be given
+               if (Objects.equals(faxNumber1, faxNumber2)) {
+                       // Both are same
+                       return 0;
+               } else if (null == faxNumber1) {
+                       // First is null
+                       return -1;
+               } else if (null == faxNumber2) {
+                       // Second is null
+                       return 1;
+               }
+
+               // Invoke compareTo() method
+               return faxNumber1.compareTo(faxNumber2);
+       }
+
        /**
         * Copy all fields from source object to this
         * <p>
index 89fc25ec4fa9521643e426f62c4e8e4cdf9077d6..d9fbe81bf7430cfd398cfd4d0bbca53641c0835d 100644 (file)
@@ -32,6 +32,31 @@ public class LandLineNumberUtils implements Serializable {
         */
        private static final long serialVersionUID = 18_698_467_372_167_561L;
 
+       /**
+        * Compares two mobile number instances with each other
+        * <p>
+        * @param landLineNumber1 First instance of a DialableLandLineNumber class
+        * @param landLineNumber2 Second instance of a DialableLandLineNumber class
+        * <p>
+        * @return Comparison value
+        */
+       public static int compare (final DialableLandLineNumber landLineNumber1, final DialableLandLineNumber landLineNumber2) {
+               // Check equality, then at least first must be given
+               if (Objects.equals(landLineNumber1, landLineNumber2)) {
+                       // Both are same
+                       return 0;
+               } else if (null == landLineNumber1) {
+                       // First is null
+                       return -1;
+               } else if (null == landLineNumber2) {
+                       // Second is null
+                       return 1;
+               }
+
+               // Invoke compareTo() method
+               return landLineNumber1.compareTo(landLineNumber2);
+       }
+
        /**
         * Copy all fields from source object to this
         * <p>
index 805f0c1e13cf75e37d9dc7357b152064baf79cf2..5bef495e7fcc5dc85f470ad6142d963334650d63 100644 (file)
@@ -32,6 +32,31 @@ public class MobileNumberUtils implements Serializable {
         */
        private static final long serialVersionUID = 291_608_496_882_761L;
 
+       /**
+        * Compares two mobile number instances with each other
+        * <p>
+        * @param mobileNumber1 First instance of a DialableMobileNumber class
+        * @param mobileNumber2 Second instance of a DialableMobileNumber class
+        * <p>
+        * @return Comparison value
+        */
+       public static int compare (final DialableMobileNumber mobileNumber1, final DialableMobileNumber mobileNumber2) {
+               // Check equality, then at least first must be given
+               if (Objects.equals(mobileNumber1, mobileNumber2)) {
+                       // Both are same
+                       return 0;
+               } else if (null == mobileNumber1) {
+                       // First is null
+                       return -1;
+               } else if (null == mobileNumber2) {
+                       // Second is null
+                       return 1;
+               }
+
+               // Invoke compareTo() method
+               return mobileNumber1.compareTo(mobileNumber2);
+       }
+
        /**
         * Copy all fields from source object to this
         * <p>
index c403a47c8b4eee15aab21698717496abf9260df7..37b789125f8ea4a32b5df0d51b3dea085b5ece8e 100644 (file)
@@ -33,8 +33,29 @@ public class MobileProviderUtils implements Serializable {
         */
        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.
+       /**
+        * Compares two mobile provider instances with each other
+        * <p>
+        * @param mobileProvider1 First instance of a MobileProvider class
+        * @param mobileProvider2 Second instance of a MobileProvider class
+        * <p>
+        * @return Comparison value
+        */
+       public static int compare (final MobileProvider mobileProvider1, final MobileProvider mobileProvider2) {
+               // Check equality, then at least first must be given
+               if (Objects.equals(mobileProvider1, mobileProvider2)) {
+                       // Both are same
+                       return 0;
+               } else if (null == mobileProvider1) {
+                       // First is null
+                       return -1;
+               } else if (null == mobileProvider2) {
+                       // Second is null
+                       return 1;
+               }
+
+               // Invoke compareTo() method
+               return mobileProvider1.compareTo(mobileProvider2);
        }
 
        /**