[java] Deleting unnecessary check, looping over an empty collection is OK
import java.io.PrintStream;
import java.util.Map;
-import java.util.Set;
import java.util.TreeMap;
public class HelpFlags {
@@ -92,17 +91,12 @@ public boolean dumpConfig(Config config, PrintStream dumpTo) {
continue;
}
- Set<String> allOptions = config.getOptions(section);
- if (allOptions.isEmpty()) {
- continue;
- }
-
- for (String option : allOptions) {
+ config.getOptions(section).forEach(option -> {
config.get(section, option).ifPresent(value -> {
Map<String, Object> values = toOutput.computeIfAbsent(section, ignored -> new TreeMap<>());
values.put(option, value);
});
- }
+ });
}
dumpTo.print(new Json().toJson(toOutput));
