Skip to content

Commit

Permalink
Change default handling in lookup() Fix function. (#356)
Browse files Browse the repository at this point in the history
According to last discussion:

* `default` from options.
* `__default` from map.
  • Loading branch information
blackwinter committed Sep 24, 2024
1 parent a505fc5 commit 27634d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions metafix/src/main/java/org/metafacture/metafix/FixMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,7 @@ public void apply(final Metafix metafix, final Record record, final List<String>
map = metafix.getMap(mapName);
}

final String defaultOption = options.get("default");
final String defaultValue = options.getOrDefault(Maps.DEFAULT_MAP_KEY, map.get(Maps.DEFAULT_MAP_KEY));
final String defaultValue = options.getOrDefault("default", map.get(Maps.DEFAULT_MAP_KEY));
final boolean delete = getBoolean(options, "delete");
final boolean printUnknown = getBoolean(options, "print_unknown");

Expand All @@ -531,7 +530,8 @@ public void apply(final Metafix metafix, final Record record, final List<String>
if (c != null) {
c.accept(oldValue);
}
return defaultOption != null ? defaultOption : defaultValue != null ? defaultValue : delete ? null : oldValue;

return defaultValue != null ? defaultValue : delete ? null : oldValue;
}
});

Expand Down

0 comments on commit 27634d1

Please sign in to comment.