Skip to content

Commit

Permalink
WIP to use the default option as in catmandu #333
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Jun 6, 2024
1 parent c403afa commit 18b78f0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion metafix/src/main/java/org/metafacture/metafix/FixMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ public void apply(final Metafix metafix, final Record record, final List<String>
final String defaultValue = map.get(Maps.DEFAULT_MAP_KEY); // TODO: Catmandu uses 'default'
final boolean delete = getBoolean(options, "delete");
final boolean printUnknown = getBoolean(options, "print_unknown");
final String defaultOption = options.get("default");

final Consumer<Consumer<String>> consumer = c -> record.transform(params.get(0), oldValue -> {
final String newValue = map.get(oldValue);
Expand All @@ -530,8 +531,11 @@ public void apply(final Metafix metafix, final Record record, final List<String>
if (c != null) {
c.accept(oldValue);
}

elsif (defaultOption != null){
return defaultOption;
}
return defaultValue != null ? defaultValue : delete ? null : oldValue;

}
});

Expand Down

0 comments on commit 18b78f0

Please sign in to comment.