From fb11fb91a1212f4e50d4346c1cacca25dca70b56 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 30 Aug 2016 12:01:34 +0200 Subject: [PATCH] better test more fields being set before let it crash into NPE --- src/org/mxchange/jusercore/model/user/UserUtils.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- 2.39.5