Skip to content

Commit 178cae7

Browse files
committed
DefaultModuleService: change persisting of items
Disable the persisting of a ModuleItems if an initialize() method is set and is not empty. This way, initialize() can overwrite the value of a ModuleItem even if persist=true is assumed implicitly. See: * imagej/imagej-legacy#137 (comment)
1 parent ea8c647 commit 178cae7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/org/scijava/module/DefaultModuleService.java

+3
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ public ModuleItem<?> getSingleOutput(Module module, Collection<Class<?>> types)
279279
public <T> void save(final ModuleItem<T> item, final T value) {
280280
if (!item.isPersisted()) return;
281281

282+
// NB: Do not persist values which are computed via an initializer.
283+
if (item.getInitializer() != null && !item.getInitializer().isEmpty()) return;
284+
282285
if (MiscUtils.equal(item.getDefaultValue(), value)) {
283286
// NB: Do not persist the value if it is the default.
284287
// This is nice if the default value might change later,

0 commit comments

Comments
 (0)