From 86e9cbc298058c0f8e6036253526aa18acd4f289 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 19 Apr 2020 06:01:08 +0200 Subject: [PATCH] Continued: - always validate parameter of public/package/protected methods and constructors - renamed i18nKey to messageKey MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../model/customer/ContactCustomer.java | 15 +++++++++++++++ .../customer/status/CustomerAccountStatus.java | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/org/mxchange/jcustomercore/model/customer/ContactCustomer.java b/src/org/mxchange/jcustomercore/model/customer/ContactCustomer.java index 72029c7..6b95a61 100644 --- a/src/org/mxchange/jcustomercore/model/customer/ContactCustomer.java +++ b/src/org/mxchange/jcustomercore/model/customer/ContactCustomer.java @@ -142,6 +142,21 @@ public class ContactCustomer implements Customer { // Call other constructor this(); + // Validate parameter + if (null == customerAccountStatus) { + // Throw NPE + throw new NullPointerException("customerAccountStatus is null"); //NOI18N + } else if (null == customerContact) { + // Throw NPE again + throw new NullPointerException("customerContact is null"); //NOI18N + } else if (null == customerNumber) { + // Throw NPE again + throw new NullPointerException("customerNumber is null"); //NOI18N + } else if (customerNumber.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("customerNumber is empty"); //NOI18N + } + // Set all parameter this.customerAccountStatus = customerAccountStatus; this.customerContact = customerContact; diff --git a/src/org/mxchange/jcustomercore/model/customer/status/CustomerAccountStatus.java b/src/org/mxchange/jcustomercore/model/customer/status/CustomerAccountStatus.java index c873b5b..98a0e43 100644 --- a/src/org/mxchange/jcustomercore/model/customer/status/CustomerAccountStatus.java +++ b/src/org/mxchange/jcustomercore/model/customer/status/CustomerAccountStatus.java @@ -57,6 +57,21 @@ public enum CustomerAccountStatus implements Serializable { * @param styleClass CSS style class */ private CustomerAccountStatus (final String messageKey, final String styleClass) { + // Validate parameter + if (null == messageKey) { + // Throw NPE + throw new NullPointerException("messageKey is null"); //NOI18N + } else if (messageKey.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("messageKey is empty"); //NOI18N + } else if (null == styleClass) { + // Throw NPE + throw new NullPointerException("styleClass is null"); //NOI18N + } else if (styleClass.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("styleClass is empty"); //NOI18N + } + // Set it here this.messageKey = messageKey; this.styleClass = styleClass; -- 2.39.5