]> git.mxchange.org Git - jcontacts-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 3 Nov 2022 20:52:24 +0000 (21:52 +0100)
committerRoland Häder <roland@mxchange.org>
Thu, 3 Nov 2022 20:52:24 +0000 (21:52 +0100)
- renamed TitleUtils to PersonalTitleUtils
- removed null-check as enumerations won't have this

src/org/mxchange/jcontacts/model/contact/gender/Gender.java
src/org/mxchange/jcontacts/model/contact/title/PersonalTitle.java
src/org/mxchange/jcontacts/model/contact/title/PersonalTitleUtils.java [new file with mode: 0644]
src/org/mxchange/jcontacts/model/contact/title/TitleUtils.java [deleted file]

index ff5041ac0a76b11dbec9ad07d72f2e08309d18b4..72a1b17e044b6e9da95cf298cc0d64739ea08ed3 100644 (file)
@@ -53,15 +53,6 @@ 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;
index b74f5714bfc2e9cfc2940d538e461b2a18733308..4de2adfcbb33b14b39b238a7e237833fa301fb53 100644 (file)
@@ -53,15 +53,6 @@ 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;
diff --git a/src/org/mxchange/jcontacts/model/contact/title/PersonalTitleUtils.java b/src/org/mxchange/jcontacts/model/contact/title/PersonalTitleUtils.java
new file mode 100644 (file)
index 0000000..419fb2a
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2016 - 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontacts.model.contact.title;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Title utilities class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class PersonalTitleUtils implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 185_683_479_107L;
+
+       /**
+        * Cache for valid chars
+        */
+       private static char[] validChars;
+
+       /**
+        * Getter for personal title enumeration from given character
+        * <p>
+        * @param c PersonalTitle character
+        * <p>
+        * @return PersonalTitle enumeration
+        */
+       public static PersonalTitle getPersonalTitleFromChar (final char c) {
+               // Init variable
+               PersonalTitle found = null;
+
+               // Loop through all
+               for (final PersonalTitle title : PersonalTitle.values()) {
+                       // Does the char match?
+                       if (c == title.getAccessChar()) {
+                               // Found it
+                               found = title;
+                               break;
+                       }
+               }
+
+               // Still null?
+               if (null == found) {
+                       // Didn't found a valid one
+                       throw new IllegalArgumentException(MessageFormat.format("Gender {0} is invalid.", c)); //NOI18N
+               }
+
+               // Return it
+               return found;
+       }
+
+       /**
+        * Valid chars (mostly for console client)
+        * <p>
+        * @return Valid chars
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public static char[] validChars () {
+               // Is cache set?
+               if (validChars != null) {
+                       // Return it
+                       return validChars;
+               }
+
+               // Init array, only 2 are valid.
+               char[] valid = new char[2];
+
+               // Get values
+               int i = 0;
+               for (final PersonalTitle title : PersonalTitle.values()) {
+                       // Get access key as this is also the access
+                       valid[i] = title.getAccessChar();
+
+                       // Increment index
+                       i++;
+               }
+
+               // Set it here
+               validChars = valid;
+
+               // Return finialized array
+               return valid;
+       }
+
+       /**
+        * Private constructor as this is an utility class
+        */
+       private PersonalTitleUtils () {
+       }
+
+}
diff --git a/src/org/mxchange/jcontacts/model/contact/title/TitleUtils.java b/src/org/mxchange/jcontacts/model/contact/title/TitleUtils.java
deleted file mode 100644 (file)
index 0d100d7..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2016 - 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontacts.model.contact.title;
-
-import java.io.Serializable;
-import java.text.MessageFormat;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Title utilities class
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class TitleUtils implements Serializable {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 185_683_479_107L;
-
-       /**
-        * Cache for valid chars
-        */
-       private static char[] validChars;
-
-       /**
-        * Getter for personal title enumeration from given character
-        * <p>
-        * @param c PersonalTitle character
-        * <p>
-        * @return PersonalTitle enumeration
-        */
-       public static PersonalTitle getPersonalTitleFromChar (final char c) {
-               // Init variable
-               PersonalTitle found = null;
-
-               // Loop through all
-               for (final PersonalTitle title : PersonalTitle.values()) {
-                       // Does the char match?
-                       if (c == title.getAccessChar()) {
-                               // Found it
-                               found = title;
-                               break;
-                       }
-               }
-
-               // Still null?
-               if (null == found) {
-                       // Didn't found a valid one
-                       throw new IllegalArgumentException(MessageFormat.format("Gender {0} is invalid.", c)); //NOI18N
-               }
-
-               // Return it
-               return found;
-       }
-
-       /**
-        * Valid chars (mostly for console client)
-        * <p>
-        * @return Valid chars
-        */
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public static char[] validChars () {
-               // Is cache set?
-               if (validChars != null) {
-                       // Return it
-                       return validChars;
-               }
-
-               // Init array, only 2 are valid.
-               char[] valid = new char[2];
-
-               // Get values
-               int i = 0;
-               for (final PersonalTitle title : PersonalTitle.values()) {
-                       // Get access key as this is also the access
-                       valid[i] = title.getAccessChar();
-
-                       // Increment index
-                       i++;
-               }
-
-               // Set it here
-               validChars = valid;
-
-               // Return finialized array
-               return valid;
-       }
-
-       /**
-        * Private constructor as this is an utility class
-        */
-       private TitleUtils () {
-       }
-
-}