this.setUserProfileMode(user.getUserProfileMode());
}
- /**
- * Uniquely adds given user instance to user list. First an existing
- * instance will be removed, then the given instance is being added.
- * <p>
- * @param user User instance to add
- */
- private void uniqueAddUser (final User user) {
- // Make sure the instance is valid
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserContact() == null) {
- // Throw again ...
- throw new NullPointerException("user.userContact is null"); //NOI18N
- }
-
- // Get iterator from list
- Iterator<User> iterator = this.userList.iterator();
-
- // "Walk" through all entries
- while (iterator.hasNext()) {
- // Get next element
- User next = iterator.next();
-
- // Is id number the same?
- if (Objects.equals(user.getUserId(), next.getUserId())) {
- // Found entry, so remove it and abort
- this.userList.remove(next);
- break;
- }
- }
-
- // Add contact to list
- this.userList.add(user);
- }
-
/**
* Updates list with given user instance
* <p>
if (null == user) {
// Throw NPE
throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserContact() == null) {
- // Throw again ...
- throw new NullPointerException("user.userContact is null"); //NOI18N
} else if (user.getUserId() == null) {
// ... again NPE
throw new NullPointerException("user.userId is null"); //NOI18N
} else if (user.getUserId() < 1) {
// Invalid id
throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
+ } else if (user.getUserContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("user.userContact is null"); //NOI18N
+ } else if (user.getUserContact().getContactId() == null) {
+ // Throw again ...
+ throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
+ } else if (user.getUserContact().getContactId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("user.userContact.contactId={0} is invalid.", user.getUserContact().getContactId())); //NOI18N
}
// Get iterator from list