+ @Override
+ public int compareTo (final Contact contact) {
+ // Checkparameter and return 0 if equal
+ if (null == contact) {
+ // Should not happen
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.equals(this)) {
+ // Same object
+ return 0;
+ }
+
+ // Init comparators
+ final int comparators[] = {
+ // First check country
+ this.getContactCountry().compareTo(contact.getContactCountry()),
+ // ... then ZIP code
+ SafeNumberUtils.compare(this.getContactZipCode(), contact.getContactZipCode()),
+ // ... and city
+ StringUtils.compare(this.getContactCity(), contact.getContactCity()),
+ // ... street name
+ StringUtils.compareIgnoreCase(this.getContactStreet(), contact.getContactStreet()),
+ // ... house number
+ SafeNumberUtils.compare(this.getContactHouseNumber(), contact.getContactHouseNumber()),
+ // ... extension
+ 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.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.compareIgnoreCase(this.getContactEmailAddress(), contact.getContactEmailAddress()),};
+
+ // Check all values
+ final int comparison = Comparables.checkAll(comparators);
+
+ // Return value
+ return comparison;
+ }
+