From a3afbbfbf7855f23e8f0ea9df36b81806b1e64c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 6 Oct 2022 15:12:34 +0200 Subject: [PATCH] Continued: - renamed class Contacts to ContactUtils - used newly introduced method CountryUtils.compare() which is null-safe --- .../model/contact/{Contacts.java => ContactUtils.java} | 4 ++-- src/org/mxchange/jcontacts/model/contact/UserContact.java | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) rename src/org/mxchange/jcontacts/model/contact/{Contacts.java => ContactUtils.java} (99%) diff --git a/src/org/mxchange/jcontacts/model/contact/Contacts.java b/src/org/mxchange/jcontacts/model/contact/ContactUtils.java similarity index 99% rename from src/org/mxchange/jcontacts/model/contact/Contacts.java rename to src/org/mxchange/jcontacts/model/contact/ContactUtils.java index 4ee599f..45b3e1b 100644 --- a/src/org/mxchange/jcontacts/model/contact/Contacts.java +++ b/src/org/mxchange/jcontacts/model/contact/ContactUtils.java @@ -32,7 +32,7 @@ import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; *

* @author Roland Häder */ -public class Contacts implements Serializable { +public class ContactUtils implements Serializable { /** * Serial number @@ -295,7 +295,7 @@ public class Contacts implements Serializable { /** * Private constructor for utilities */ - private Contacts () { + private ContactUtils () { } } diff --git a/src/org/mxchange/jcontacts/model/contact/UserContact.java b/src/org/mxchange/jcontacts/model/contact/UserContact.java index 93cdfa3..81c10a2 100644 --- a/src/org/mxchange/jcontacts/model/contact/UserContact.java +++ b/src/org/mxchange/jcontacts/model/contact/UserContact.java @@ -41,6 +41,7 @@ import org.apache.commons.lang3.StringUtils; import org.mxchange.jcontacts.model.contact.title.PersonalTitle; import org.mxchange.jcoreutils.Comparables; import org.mxchange.jcoreutils.SafeNumberUtils; +import org.mxchange.jcountry.model.data.CountryUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountryData; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -273,7 +274,7 @@ public class UserContact implements Contact { // Init comparators final int comparators[] = { // First check country - this.getContactCountry().compareTo(contact.getContactCountry()), + CountryUtils.compare(this.getContactCountry(), contact.getContactCountry()), // ... then ZIP code SafeNumberUtils.compare(this.getContactZipCode(), contact.getContactZipCode()), // ... and city @@ -289,9 +290,9 @@ public class UserContact implements Contact { // ... academical title StringUtils.compareIgnoreCase(this.getContactTitle(), contact.getContactTitle()), // .. family name is next ... - this.getContactFamilyName().compareToIgnoreCase(contact.getContactFamilyName()), + StringUtils.compareIgnoreCase(this.getContactFamilyName(), contact.getContactFamilyName()), // .. first name is second ... - this.getContactFirstName().compareToIgnoreCase(contact.getContactFirstName()), + StringUtils.compareIgnoreCase(this.getContactFirstName(), contact.getContactFirstName()), // ... next is email address StringUtils.compareIgnoreCase(this.getContactEmailAddress(), contact.getContactEmailAddress()),}; -- 2.39.5