adoroszlai commented on a change in pull request #1051: URL: https://github.com/apache/hadoop-ozone/pull/1051#discussion_r439741987
########## File path: hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ListPipelinesSubcommand.java ########## @@ -54,17 +54,12 @@ @Override public Void call() throws Exception { try (ScmClient scmClient = parent.getParent().createScmClient()) { - if (Strings.isNullOrEmpty(factor) && Strings.isNullOrEmpty(state)) { - scmClient.listPipelines().forEach(System.out::println); - } else { - scmClient.listPipelines().stream() - .filter(p -> ((Strings.isNullOrEmpty(factor) || - (p.getFactor().toString().compareToIgnoreCase(factor) == 0)) - && (Strings.isNullOrEmpty(state) || - (p.getPipelineState().toString().compareToIgnoreCase(state) - == 0)))) - .forEach(System.out::println); - } + scmClient.listPipelines().stream() + .filter(p -> ((Strings.isNullOrEmpty(factor) + || (p.getFactor().toString().compareToIgnoreCase(factor) == 0)) + && (Strings.isNullOrEmpty(state) || (p.getPipelineState() + .toString().compareToIgnoreCase(state) == 0)))) + .forEach(System.out::println); Review comment: Structuring this as below would reduce duplication, and make it easier to add further filters if needed: ``` Stream<...> stream = scmClient.listPipelines().stream(); if (!isNullOrEmpty(factor)) { stream = stream.filter(...); } if (!isNullOrEmpty(state)) { stream = stream.filter(...); } stream.forEach(...); ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org