From: Roland Häder Date: Tue, 30 Aug 2016 10:01:34 +0000 (+0200) Subject: better test more fields being set before let it crash into NPE X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fb11fb91a1212f4e50d4346c1cacca25dca70b56;p=juser-core.git better test more fields being set before let it crash into NPE --- diff --git a/src/org/mxchange/jusercore/model/user/UserUtils.java b/src/org/mxchange/jusercore/model/user/UserUtils.java index ebd64ef..0ab7e74 100644 --- a/src/org/mxchange/jusercore/model/user/UserUtils.java +++ b/src/org/mxchange/jusercore/model/user/UserUtils.java @@ -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