Skip to content

Commit

Permalink
Adjust delete function as suggested by @blackwinter #333
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Sep 9, 2024
1 parent 5cb5e66 commit 1e4938e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions metafix/src/main/java/org/metafacture/metafix/FixMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,10 @@ public void apply(final Metafix metafix, final Record record, final List<String>
map = metafix.getMap(mapName);
}

final String defaultValue = map.get(Maps.DEFAULT_MAP_KEY); // TODO: Catmandu uses 'default'
final String defaultOption = options.get("default");
final String defaultValue = options.getOrDefault(Maps.DEFAULT_MAP_KEY, defaultOption);
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 @@ -531,11 +531,7 @@ 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 1e4938e

Please sign in to comment.