]> git.mxchange.org Git - jproduct-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 19 Apr 2020 04:10:41 +0000 (06:10 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 19 Apr 2020 04:10:41 +0000 (06:10 +0200)
- always validate parameter of public/package/protected methods and constructors
- renamed i18nKey to messageKey

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jproduct/model/payment/PaymentType.java
src/org/mxchange/jproduct/model/product/agegroup/AgeGroup.java

index 4d9838bc3da7e87d2bd500ebf74be4ba46dd7158..fbb7a8c280e444ed71a588ce19857285f574aec7 100644 (file)
@@ -47,16 +47,25 @@ public enum PaymentType {
        /**
         * I18n key
         */
-       private final String i18nKey;
+       private final String messageKey;
 
        /**
         * Constructor with i18n key
         * <p>
-        * @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 {
         * <p>
         * @return I18n key
         */
-       public String getI18nKey () {
-               return this.i18nKey;
+       public String getMessageKey () {
+               return this.messageKey;
        }
 
 }
index 54398c35c9d413350bd898775abc1e5137fad840..c9f9455b6bdc202e3d2d2332124b948382613a90 100644 (file)
@@ -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
         * <p>
-        * @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 {
         * <p>
         * @return Age group's i18n key
         */
-       public String getI18nKey () {
-               return this.i18nKey;
+       public String getMessageKey () {
+               return this.messageKey;
        }
 
 }