Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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)
  • Loading branch information
stelfrich committed Aug 8, 2016
commit 876e9bf6c9186a38c69511d198b2fb72273bce7b
3 changes: 3 additions & 0 deletions src/main/java/org/scijava/module/DefaultModuleService.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ public ModuleItem<?> getSingleOutput(Module module, Collection<Class<?>> types)
public <T> void save(final ModuleItem<T> item, final T value) {
if (!item.isPersisted()) return;

// NB: Do not persist values which are computed via an initializer.
if (item.getInitializer() != null && !item.getInitializer().isEmpty()) return;

if (MiscUtils.equal(item.getDefaultValue(), value)) {
// NB: Do not persist the value if it is the default.
// This is nice if the default value might change later,
Expand Down