From 4006382e7657f619d24de0ec9d793e682d6543ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 16 Aug 2016 11:10:53 +0200 Subject: [PATCH] Renaming season has started: - renamed cellphone to mobile (all occurences) - let's don't discrimite other mobile phones, right? --- src/org/mxchange/jphone/utils/PhoneUtils.java | 250 +++++++++--------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/src/org/mxchange/jphone/utils/PhoneUtils.java b/src/org/mxchange/jphone/utils/PhoneUtils.java index ed9bba6..66db176 100644 --- a/src/org/mxchange/jphone/utils/PhoneUtils.java +++ b/src/org/mxchange/jphone/utils/PhoneUtils.java @@ -1,125 +1,125 @@ -/* - * 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 . - */ -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 - */ -public class PhoneUtils implements Serializable { - - /** - * Serial number - */ - private static final long serialVersionUID = 183_598_328_176_450L; - - /** - * Checks if both are the same - *

- * @param cellphoneNumber Cellphone number 1 - * @param otherNumber Cellphone number 2 - *

- * @return Whether both are the same number - */ - public static boolean isSameCellphoneNumber (final DialableMobileNumber cellphoneNumber, final DialableMobileNumber otherNumber) { - // Test object equality first - if (Objects.equals(cellphoneNumber, otherNumber)) { - // Both the same object (null/null or same object) - return true; - } else if (((null == cellphoneNumber) && (otherNumber instanceof DialableMobileNumber)) || ((null == otherNumber) && (cellphoneNumber instanceof DialableMobileNumber))) { - // One is null the other not - return false; - } - - // Now compare deeper - @SuppressWarnings ("null") - boolean sameProvider = Objects.equals(cellphoneNumber.getMobileProvider(), otherNumber.getMobileProvider()); - boolean sameNumber = Objects.equals(cellphoneNumber.getPhoneNumber(), otherNumber.getPhoneNumber()); - - // All are the same? - return (sameProvider && sameNumber); - } - - /** - * Checks if both are the same - *

- * @param faxNumber First fax number - * @param otherNumber Second fax number - *

- * @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 - *

- * @param landLineNumber First land-line number - * @param otherNumber Second land-line number - *

- * @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); - } - - /** - * Private constructor for utility classes - */ - private PhoneUtils () { - } - -} +/* + * 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 . + */ +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 + */ +public class PhoneUtils implements Serializable { + + /** + * Serial number + */ + private static final long serialVersionUID = 183_598_328_176_450L; + + /** + * Checks if both are the same + *

+ * @param faxNumber First fax number + * @param otherNumber Second fax number + *

+ * @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 + *

+ * @param landLineNumber First land-line number + * @param otherNumber Second land-line number + *

+ * @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 + *

+ * @param mobileNumber Mobile number 1 + * @param otherNumber Mobile number 2 + *

+ * @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 () { + } + +} -- 2.39.5