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
}
@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;
}
// 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
+++ /dev/null
-/*
- * 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 () {
- }
-
-}
+++ /dev/null
-/*
- * 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 () {
- }
-
-}
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
// 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
+++ /dev/null
-/*
- * 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 () {
- }
-
-}
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
}
@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
+++ /dev/null
-/*
- * 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 () {
- }
-
-}
--- /dev/null
+/*
+ * 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 () {
+ }
+
+}
--- /dev/null
+/*
+ * 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 () {
+ }
+
+}
--- /dev/null
+/*
+ * 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 () {
+ }
+
+}
--- /dev/null
+/*
+ * 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 () {
+ }
+
+}