+ /**
+ * Removes given contact from all lists
+ * <p>
+ * @param contact Contact instance to remove
+ */
+ private void removeContact (final Contact contact) {
+ // Is the instance valid?
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+ }
+
+ // Remove from general list
+ if (!this.contactList.remove(contact)) {
+ // Did not remove contact
+ throw new IllegalStateException(MessageFormat.format("contact {0} was not removed.", contact.getContactId())); //NOI18N
+ }
+
+ // Remove from other lists
+ this.emailAddressList.remove(contact.getContactEmailAddress());
+ }
+