-/*\r
- * Copyright (C) 2016 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jphone.utils;\r
-\r
-import java.io.Serializable;\r
-import java.util.Objects;\r
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;\r
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;\r
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;\r
-\r
-/**\r
- *\r
- * @author Roland Haeder<roland@mxchange.org>\r
- */\r
-public class PhoneUtils implements Serializable {\r
-\r
- /**\r
- * Serial number\r
- */\r
- private static final long serialVersionUID = 183_598_328_176_450L;\r
-\r
- /**\r
- * Checks if both are the same\r
- * <p>\r
- * @param cellphoneNumber Cellphone number 1\r
- * @param otherNumber Cellphone number 2\r
- * <p>\r
- * @return Whether both are the same number\r
- */\r
- public static boolean isSameCellphoneNumber (final DialableMobileNumber cellphoneNumber, final DialableMobileNumber otherNumber) {\r
- // Test object equality first\r
- if (Objects.equals(cellphoneNumber, otherNumber)) {\r
- // Both the same object (null/null or same object)\r
- return true;\r
- } else if (((null == cellphoneNumber) && (otherNumber instanceof DialableMobileNumber)) || ((null == otherNumber) && (cellphoneNumber instanceof DialableMobileNumber))) {\r
- // One is null the other not\r
- return false;\r
- }\r
-\r
- // Now compare deeper\r
- @SuppressWarnings ("null")\r
- boolean sameProvider = Objects.equals(cellphoneNumber.getMobileProvider(), otherNumber.getMobileProvider());\r
- boolean sameNumber = Objects.equals(cellphoneNumber.getPhoneNumber(), otherNumber.getPhoneNumber());\r
-\r
- // All are the same?\r
- return (sameProvider && sameNumber);\r
- }\r
-\r
- /**\r
- * Checks if both are the same\r
- * <p>\r
- * @param faxNumber First fax number\r
- * @param otherNumber Second fax number\r
- * <p>\r
- * @return Whether both are the same\r
- */\r
- public static boolean isSameFaxNumber (final DialableFaxNumber faxNumber, DialableFaxNumber otherNumber) {\r
- // Test object equality first\r
- if (Objects.equals(faxNumber, otherNumber)) {\r
- // Both the same object (null/null or same object)\r
- return true;\r
- } else if (((null == faxNumber) && (otherNumber instanceof DialableFaxNumber)) || ((null == otherNumber) && (faxNumber instanceof DialableFaxNumber))) {\r
- // One is null the other not\r
- return false;\r
- }\r
-\r
- // Now compare deeper\r
- @SuppressWarnings ("null")\r
- boolean sameCountry = Objects.equals(faxNumber.getPhoneCountry(), otherNumber.getPhoneCountry());\r
- boolean sameAreaCode = Objects.equals(faxNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode());\r
- boolean sameNumber = Objects.equals(faxNumber.getPhoneNumber(), otherNumber.getPhoneNumber());\r
-\r
- // All are the same?\r
- return (sameCountry && sameAreaCode && sameNumber);\r
- }\r
-\r
- /**\r
- * Checks if both are the same\r
- * <p>\r
- * @param landLineNumber First land-line number\r
- * @param otherNumber Second land-line number\r
- * <p>\r
- * @return Whether both are the same\r
- */\r
- public static boolean isSameLandLineNumber (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber otherNumber) {\r
- // Test object equality first\r
- if (Objects.equals(landLineNumber, otherNumber)) {\r
- // Both the same object (null/null or same object)\r
- return true;\r
- } else if (((null == landLineNumber) && (otherNumber instanceof DialableLandLineNumber)) || ((null == otherNumber) && (landLineNumber instanceof DialableLandLineNumber))) {\r
- // One is null the other not\r
- return false;\r
- }\r
-\r
- // Now compare deeper\r
- @SuppressWarnings ("null")\r
- boolean sameCountry = Objects.equals(landLineNumber.getPhoneCountry(), otherNumber.getPhoneCountry());\r
- boolean sameAreaCode = Objects.equals(landLineNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode());\r
- boolean sameNumber = Objects.equals(landLineNumber.getPhoneNumber(), otherNumber.getPhoneNumber());\r
-\r
- // All are the same?\r
- return (sameCountry && sameAreaCode && sameNumber);\r
- }\r
-\r
- /**\r
- * Private constructor for utility classes\r
- */\r
- private PhoneUtils () {\r
- }\r
-\r
-}\r
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+
+/**
+ *
+ * @author Roland Haeder<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 () {
+ }
+
+}