You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/02/12 07:35:09 UTC

[GitHub] [incubator-seatunnel] yx91490 commented on a change in pull request #1214: [hotfix] Add List type check for CheckConfigUtil

yx91490 commented on a change in pull request #1214:
URL: https://github.com/apache/incubator-seatunnel/pull/1214#discussion_r805131045



##########
File path: seatunnel-common/src/main/java/org/apache/seatunnel/common/config/CheckConfigUtil.java
##########
@@ -72,6 +72,16 @@ public static CheckResult checkAtLeastOneExists(Config config, String... params)
         }
     }
 
+    public static boolean isInvalidParam(Config config, String param) {
+        boolean isInvalidParam = false;
+        if (!config.hasPath(param) || config.getAnyRef(param) == null) {
+            isInvalidParam = true;
+        } else if (config.getAnyRef(param) instanceof List) {

Review comment:
       such as intList, do you have idea to check list type? 

##########
File path: seatunnel-common/src/main/java/org/apache/seatunnel/common/config/CheckConfigUtil.java
##########
@@ -72,6 +72,16 @@ public static CheckResult checkAtLeastOneExists(Config config, String... params)
         }
     }
 
+    public static boolean isInvalidParam(Config config, String param) {
+        boolean isInvalidParam = false;
+        if (!config.hasPath(param) || config.getAnyRef(param) == null) {
+            isInvalidParam = true;
+        } else if (config.getAnyRef(param) instanceof List) {
+            isInvalidParam = ((List<?>) config.getAnyRef(param)).size() == 0;

Review comment:
       can be simplified to config.getAnyRefList(param).isEmpty()

##########
File path: seatunnel-common/src/main/java/org/apache/seatunnel/common/config/CheckConfigUtil.java
##########
@@ -72,6 +72,16 @@ public static CheckResult checkAtLeastOneExists(Config config, String... params)
         }
     }
 
+    public static boolean isInvalidParam(Config config, String param) {

Review comment:
       It'll be more easy to understand to change to positive method name like 'isValidParam'

##########
File path: seatunnel-common/src/main/java/org/apache/seatunnel/common/config/CheckConfigUtil.java
##########
@@ -72,6 +72,16 @@ public static CheckResult checkAtLeastOneExists(Config config, String... params)
         }
     }
 
+    public static boolean isInvalidParam(Config config, String param) {
+        boolean isInvalidParam = false;
+        if (!config.hasPath(param) || config.getAnyRef(param) == null) {

Review comment:
       can be simplified, `config.hasPath()` can ensure `config.getAnyRef(param) != null`




-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org