From: Roland Häder Date: Sun, 19 Apr 2020 04:10:41 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=93a0eb5529a0520a3f40d4307b70137766ef7f16;p=jproduct-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/jproduct/model/payment/PaymentType.java b/src/org/mxchange/jproduct/model/payment/PaymentType.java index 4d9838b..fbb7a8c 100644 --- a/src/org/mxchange/jproduct/model/payment/PaymentType.java +++ b/src/org/mxchange/jproduct/model/payment/PaymentType.java @@ -47,16 +47,25 @@ public enum PaymentType { /** * I18n key */ - private final String i18nKey; + private final String messageKey; /** * Constructor with i18n key *

- * @param i18Key I18n key + * @param messageKey I18n key */ - private PaymentType (final String i18Key) { + private PaymentType (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 here - this.i18nKey = i18Key; + this.messageKey = messageKey; } /** @@ -64,8 +73,8 @@ public enum PaymentType { *

* @return I18n key */ - public String getI18nKey () { - return this.i18nKey; + public String getMessageKey () { + return this.messageKey; } } diff --git a/src/org/mxchange/jproduct/model/product/agegroup/AgeGroup.java b/src/org/mxchange/jproduct/model/product/agegroup/AgeGroup.java index 54398c3..c9f9455 100644 --- a/src/org/mxchange/jproduct/model/product/agegroup/AgeGroup.java +++ b/src/org/mxchange/jproduct/model/product/agegroup/AgeGroup.java @@ -46,21 +46,30 @@ public enum AgeGroup { /** * Age group "senior" */ - AGE_GROUP_SENIOR("AGE_GROUP_SENIOR"); //NOI18N + AGE_GROUP_SENIOR("AGE_GROUP_SENIOR"); //NOI18N//NOI18N /** * I18n key for age group/class */ - private final String i18nKey; + private final String messageKey; /** * Constructor with all enumeration fields *

- * @param i18nKey I18n key for age class + * @param messageKey I18n key for age class */ - private AgeGroup (final String i18nKey) { + private AgeGroup (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 all values - this.i18nKey = i18nKey; + this.messageKey = messageKey; } /** @@ -68,8 +77,8 @@ public enum AgeGroup { *

* @return Age group's i18n key */ - public String getI18nKey () { - return this.i18nKey; + public String getMessageKey () { + return this.messageKey; } }