From 53897becb9cd48bba4608d0b2b25f531ded00353 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 9 Jun 2017 21:43:54 +0200 Subject: [PATCH] Please cherry-pick: - added more checks on parameters (AKA sanity-check) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../database/BaseFinancialsDatabaseBean.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java b/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java index b44baec..53710cc 100644 --- a/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java +++ b/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java @@ -475,6 +475,36 @@ public abstract class BaseFinancialsDatabaseBean extends BaseDatabaseBean { } else if (null == emailAddress) { // Throw NPE throw new NullPointerException("emailAddress is null"); //NOI18N + }else if (null == user) { + // Throw NPE + throw new NullPointerException("user is null"); //NOI18N + } else if (user.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("user.userId is null"); //NOI18N + } else if (user.getUserId() < 1) { + // Not valid number + throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N + } else if (user.getUserName() == null) { + // Throw NPE again + throw new NullPointerException("user.userName is null"); //NOI18N + } else if (user.getUserName().isEmpty()) { + // Empty string + throw new IllegalArgumentException("user.userName is empty"); //NOI18N + } 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 } // Prepare mail wrapper -- 2.39.5