From 53a805f689a4c183a9addd214ea250bd50116799 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 19 Apr 2020 06:12:38 +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 --- .../email_address/status/EmailChangeStatus.java | 12 +++++++++++- .../model/user/status/UserAccountStatus.java | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/org/mxchange/jusercore/model/email_address/status/EmailChangeStatus.java b/src/org/mxchange/jusercore/model/email_address/status/EmailChangeStatus.java index 64b1fb4..4815389 100644 --- a/src/org/mxchange/jusercore/model/email_address/status/EmailChangeStatus.java +++ b/src/org/mxchange/jusercore/model/email_address/status/EmailChangeStatus.java @@ -41,7 +41,8 @@ public enum EmailChangeStatus implements Serializable { WITHDRAWN("EMAIL_CHANGE_STATUS_WITHDRAWN"), //NOI18N /** - * User has "deleted" the entry. This is not done to keep a history of email changes. + * User has "deleted" the entry. This is not done to keep a history of email + * changes. */ DELETED("EMAIL_CHANGE_STATUS_DELETED"); //NOI18N @@ -56,6 +57,15 @@ public enum EmailChangeStatus implements Serializable { * @param messageKey Message key (i18n) */ private EmailChangeStatus (final String messageKey) { + // 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 + } + // Set it here this.messageKey = messageKey; } diff --git a/src/org/mxchange/jusercore/model/user/status/UserAccountStatus.java b/src/org/mxchange/jusercore/model/user/status/UserAccountStatus.java index e5b9a16..2caf6fd 100644 --- a/src/org/mxchange/jusercore/model/user/status/UserAccountStatus.java +++ b/src/org/mxchange/jusercore/model/user/status/UserAccountStatus.java @@ -57,6 +57,21 @@ public enum UserAccountStatus implements Serializable { * @param styleClass CSS style class */ private UserAccountStatus (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