* @param contact2 Contact instance 2
* <p>
* @return Comparison value
- * <p>
- * @throws NullPointerException If first instance is null
*/
public static int compare (final Contact contact1, final Contact contact2) {
// Check euqality, then at least first must be given
// Both are same
return 0;
} else if (null == contact1) {
- // First cannot be null
- throw new NullPointerException("contact1 is null"); //NOI18N
+ // First is null
+ return -1;
} else if (null == contact2) {
// Second is null
- return -1;
+ return 1;
}
// Invoke compareTo() method
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import org.apache.commons.lang3.StringUtils;
import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
import org.mxchange.jcoreee.utils.Comparables;
-import org.mxchange.jcoreee.utils.StringUtils;
+import org.mxchange.jcoreee.utils.CoreNumberUtils;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jcountry.model.data.CountryData;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
// First check country
this.getContactCountry().compareTo(contact.getContactCountry()),
// ... then ZIP code
- Integer.compare(this.getContactZipCode(), contact.getContactZipCode()),
+ CoreNumberUtils.compare(this.getContactZipCode(), contact.getContactZipCode()),
// ... and city
this.getContactCity().compareTo(contact.getContactCity()),
// ... street name
- StringUtils.compareToIgnoreCase(this.getContactStreet(), contact.getContactStreet()),
+ StringUtils.compareIgnoreCase(this.getContactStreet(), contact.getContactStreet()),
// ... house number
- Integer.compare(this.getContactHouseNumber(), contact.getContactHouseNumber()),
+ CoreNumberUtils.compare(this.getContactHouseNumber(), contact.getContactHouseNumber()),
// ... extension
- StringUtils.compareToIgnoreCase(this.getContactHouseNumberExtension(), contact.getContactHouseNumberExtension()),
+ StringUtils.compareIgnoreCase(this.getContactHouseNumberExtension(), contact.getContactHouseNumberExtension()),
// ... now it is sure that address is different/same, continue with personal title
this.getContactPersonalTitle().compareTo(contact.getContactPersonalTitle()),
// ... academical title
- StringUtils.compareToIgnoreCase(this.getContactTitle(), contact.getContactTitle()),
+ StringUtils.compareIgnoreCase(this.getContactTitle(), contact.getContactTitle()),
// .. family name is next ...
this.getContactFamilyName().compareToIgnoreCase(contact.getContactFamilyName()),
// .. first name is second ...
this.getContactFirstName().compareToIgnoreCase(contact.getContactFirstName()),
// ... next is email address
- StringUtils.compareToIgnoreCase(this.getContactEmailAddress(), contact.getContactEmailAddress()),};
+ StringUtils.compareIgnoreCase(this.getContactEmailAddress(), contact.getContactEmailAddress()),};
// Check all values
final int comparison = Comparables.checkAll(comparators);