From 7df4118c9b2349af841c0d43d96fa1400084c7d4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 19 Apr 2020 06:00:45 +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 --- .../mxchange/jcontacts/model/contact/gender/Gender.java | 9 +++++++++ .../jcontacts/model/contact/title/PersonalTitle.java | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/org/mxchange/jcontacts/model/contact/gender/Gender.java b/src/org/mxchange/jcontacts/model/contact/gender/Gender.java index cac5825..bd1fc45 100644 --- a/src/org/mxchange/jcontacts/model/contact/gender/Gender.java +++ b/src/org/mxchange/jcontacts/model/contact/gender/Gender.java @@ -53,6 +53,15 @@ public enum Gender implements Serializable { * @param messageKey Message key for resource file */ private Gender (final char accessChar, 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 both this.accessChar = accessChar; this.messageKey = messageKey; diff --git a/src/org/mxchange/jcontacts/model/contact/title/PersonalTitle.java b/src/org/mxchange/jcontacts/model/contact/title/PersonalTitle.java index a9a3853..36d30f3 100644 --- a/src/org/mxchange/jcontacts/model/contact/title/PersonalTitle.java +++ b/src/org/mxchange/jcontacts/model/contact/title/PersonalTitle.java @@ -53,6 +53,15 @@ public enum PersonalTitle implements Serializable { * @param messageKey Message key for resource file */ private PersonalTitle (final char accessChar, 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 both this.accessChar = accessChar; this.messageKey = messageKey; -- 2.39.5