]> git.mxchange.org Git - juser-core.git/commitdiff
better test more fields being set before let it crash into NPE
authorRoland Häder <roland@mxchange.org>
Tue, 30 Aug 2016 10:01:34 +0000 (12:01 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 30 Aug 2016 10:01:34 +0000 (12:01 +0200)
src/org/mxchange/jusercore/model/user/UserUtils.java

index ebd64ef717aa09205561cdcc94a39caeac37ad30..0ab7e74ae2742e927f149d9e146839646936bff4 100644 (file)
@@ -219,6 +219,18 @@ public class UserUtils implements Serializable {
                } else if (user.getUserAccountStatus() == null) {
                        // Throw NPE
                        throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
+               } else if (user.getUserContact() == null) {
+                       // Throw it again
+                       throw new NullPointerException("user.userContact is null"); //NOI18N
+               } else if (user.getUserContact().getContactId() == null) {
+                       // .. and again
+                       throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
+               } else if (user.getUserContact().getContactId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N
+               } else if (user.getUserContact().getContactGender() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("user.userContact.contactGender is null"); //NOI18N
                }
 
                // Init properties list