[java] Refactoring to shorten code
@@ -97,17 +97,12 @@ public boolean dumpConfig(Config config, PrintStream dumpTo) {
continue;
}
- Map<String, Object> values = new TreeMap<>();
for (String option : allOptions) {
- config.get(section, option).ifPresent(value -> values.put(option, value));
- }
-
- if (values.isEmpty()) {
- continue;
+ config.get(section, option).ifPresent(value -> {
+ Map<String, Object> values = toOutput.computeIfAbsent(section, ignored -> new TreeMap<>());
+ values.put(option, value);
+ });
}
-
- Map<String, Object> toAmend = toOutput.computeIfAbsent(section, ignored -> new TreeMap<>());
- toAmend.putAll(values);
}
dumpTo.print(new Json().toJson(toOutput));
