]> git.mxchange.org Git - jcore.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 31 Jan 2023 14:13:53 +0000 (15:13 +0100)
committerRoland Häder <roland@mxchange.org>
Tue, 9 Jan 2024 22:17:11 +0000 (23:17 +0100)
- added more checks on parameter

src/org/mxchange/jcore/utils/FrameworkUtils.java

index aef9ac026f96cdb41dd314db321f094ed2d3369a..dd6ab5802f0f052ffc6af9ca65011e0e396d2396 100644 (file)
@@ -52,8 +52,23 @@ public class FrameworkUtils {
         * @return Array from tokenized string
         */
        public static String[] getArrayFromString (final String str, final String delimiter) {
+               // Check all parameter
+               if (null == str) {
+                       // Throw NPE
+                       throw new NullPointerException("Parameter 'str' is null"); //NOI18N
+               } else if (str.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("Parameter 'str' is empty"); //NOI18N
+               } else if (null == delimiter) {
+                       // Throw NPE
+                       throw new NullPointerException("Parameter 'delimiter' is null"); //NOI18N
+               } else if (delimiter.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("Parameter 'delimiter' is empty"); //NOI18N
+               }
+
                // Get tokenizer
-               StringTokenizer tokenizer = new StringTokenizer(str, delimiter);
+               final StringTokenizer tokenizer = new StringTokenizer(str, delimiter);
 
                // Init array and index
                String[] tokens = new String[tokenizer.countTokens()];