From 27634d13c12d9d38285f40a1fce1b12eebe938ab Mon Sep 17 00:00:00 2001 From: Jens Wille Date: Tue, 24 Sep 2024 18:29:20 +0200 Subject: [PATCH] Change default handling in `lookup()` Fix function. (#356) According to last discussion: * `default` from options. * `__default` from map. --- .../src/main/java/org/metafacture/metafix/FixMethod.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metafix/src/main/java/org/metafacture/metafix/FixMethod.java b/metafix/src/main/java/org/metafacture/metafix/FixMethod.java index 81b7a9ad..bbb4c3a9 100644 --- a/metafix/src/main/java/org/metafacture/metafix/FixMethod.java +++ b/metafix/src/main/java/org/metafacture/metafix/FixMethod.java @@ -517,8 +517,7 @@ public void apply(final Metafix metafix, final Record record, final List 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"); @@ -531,7 +530,8 @@ public void apply(final Metafix metafix, final Record record, final List if (c != null) { c.accept(oldValue); } - return defaultOption != null ? defaultOption : defaultValue != null ? defaultValue : delete ? null : oldValue; + + return defaultValue != null ? defaultValue : delete ? null : oldValue; } });