You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uniffle.apache.org by GitBox <gi...@apache.org> on 2022/07/02 15:08:33 UTC

[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #9: Introduce the asList method in ConfigOptions

jerqi commented on code in PR #9:
URL: https://github.com/apache/incubator-uniffle/pull/9#discussion_r912371720


##########
common/src/main/java/com/tencent/rss/common/config/ConfigOptions.java:
##########
@@ -208,4 +217,69 @@ public ConfigOption<T> noDefaultValue() {
         converter);
     }
   }
+
+  /**
+   * Builder for {@link ConfigOption} of list of type {@link E}.
+   *
+   * @param <E> list element type of the option
+   */
+  public static class ListConfigOptionBuilder<E> {
+    private final String key;
+    private final Class<E> clazz;
+    private final Function<Object, E> atomicConverter;
+    private Function<Object, List<E>> asListConverter;
+
+    public ListConfigOptionBuilder(String key, Class<E> clazz, Function<Object, E> atomicConverter) {
+      this.key = key;
+      this.clazz = clazz;
+      this.atomicConverter = atomicConverter;
+      this.asListConverter = (v) -> {
+        return Arrays.stream(v.toString().split(LIST_SPILTTER))
+                .map(s -> atomicConverter.apply(s)).collect(Collectors.toList());
+      };
+    }
+
+    public ListConfigOptionBuilder checkValue(Function<E, Boolean> checkValueFunc, String errMsg) {
+      Function<Object, List<E>> newConverter = (v) -> {
+        List<E> list = Arrays.stream(v.toString().split(LIST_SPILTTER))
+                .map(s -> atomicConverter.apply(s)).collect(Collectors.toList());

Review Comment:
   Just curious, Do Flink support the method `checkValue`?



-- 
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: dev-unsubscribe@uniffle.apache.org

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