luoyedeyi commented on code in PR #9425:
URL: https://github.com/apache/dolphinscheduler/pull/9425#discussion_r870927110
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ParameterUtils.java:
##########
@@ -0,0 +1,61 @@
+package org.apache.dolphinscheduler.plugin.task.api.utils;
+
+import org.apache.commons.lang.math.NumberUtils;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ParameterUtils {
+ private static String NO_VALUE_KEY = "__NO_VALUE_KEY";
+ private static String DOUBLE_HYPHEN = "--";
+ private static String HYPHEN = "-";
+
+ public static Map fromArgs(String[] args) throws IllegalArgumentException
{
+ Map<String, String> map = new HashMap(args.length / 2);
+ int i = 0;
+ while (true) {
+ while (i < args.length) {
+ String key = getKeyFromArgs(args, i);
+ if (key.isEmpty()) {
+ throw new IllegalArgumentException("The input contains an
empty argument");
+ }
+
+ ++i;
+ if (i >= args.length) {
+ map.put(key, NO_VALUE_KEY);
+ } else if (NumberUtils.isNumber(args[i])) {
+ map.put(key, args[i]);
+ ++i;
+ } else if (!args[i].startsWith(DOUBLE_HYPHEN) &&
!args[i].startsWith(HYPHEN)) {
+ map.put(key, args[i]);
+ ++i;
+ } else {
+ map.put(key, NO_VALUE_KEY);
+ }
+ }
+
+ return map;
+ }
+ }
+
+ public static String getKeyFromArgs(String[] args, int index) {
Review Comment:
Deleted this code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]