From 4717494e41842e65b62adc6bbe66dbe52469f5b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 19 Apr 2020 05:59:33 +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/addressbook/UserAddressbook.java | 2 +- .../addressbook/status/AddressbokStatus.java | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java b/src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java index db8ed47..b36989b 100644 --- a/src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java @@ -123,7 +123,7 @@ public class UserAddressbook implements Addressbook { * @param addressbookUser User instance */ public UserAddressbook (final String addressbookName, final User addressbookUser) { - // Call default constructor + // Invoke default constructor this(); // Set name and user instance diff --git a/src/org/mxchange/jaddressbook/model/addressbook/status/AddressbokStatus.java b/src/org/mxchange/jaddressbook/model/addressbook/status/AddressbokStatus.java index f100182..b898219 100644 --- a/src/org/mxchange/jaddressbook/model/addressbook/status/AddressbokStatus.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/status/AddressbokStatus.java @@ -26,12 +26,12 @@ import java.io.Serializable; public enum AddressbokStatus implements Serializable { /** - * When the addressbook is unlocked + * When the address book is unlocked */ UNLOCKED("ADDRESSBOOK_STATUS_UNLOCKED"), //NOI18N /** - * When the addressbook is locked by administrator + * When the address book is locked by administrator */ LOCKED("ADDRESSBOOK_STATUS_LOCKED"); //NOI18N @@ -43,9 +43,19 @@ public enum AddressbokStatus implements Serializable { /** * Constructor *

- * @param messageKey Message key for this enum + * @param messageKey Message key for this enumeration */ private AddressbokStatus (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 message key this.messageKey = messageKey; } -- 2.39.5