From: Roland Häder Date: Sun, 19 Apr 2020 04:01:08 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=86e9cbc298058c0f8e6036253526aa18acd4f289;p=jcustomer-core.git Continued: - always validate parameter of public/package/protected methods and constructors - renamed i18nKey to messageKey Signed-off-by: Roland Häder --- 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;