Skip to content

Commit 726f69a

Browse files
committed
PluginIndex: allow null PluginFinder
The PluginFinder of a PluginIndex can now be null. If null, no plugins will be discovered during the discover() method call.
1 parent cb240ac commit 726f69a

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎src/main/java/org/scijava/plugin/PluginIndex.java‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public PluginIndex() {
8787
/**
8888
* Constructs a new plugin index which uses the given {@link PluginFinder} to
8989
* discover plugins.
90+
* <p>
91+
* A null PluginFinder is allowed, in which case no plugins will be discovered
92+
* during {@link #discover()} calls.
93+
* </p>
9094
*/
9195
@SuppressWarnings({ "rawtypes", "unchecked" })
9296
public PluginIndex(final PluginFinder pluginFinder) {
@@ -97,8 +101,12 @@ public PluginIndex(final PluginFinder pluginFinder) {
97101

98102
// -- PluginIndex methods --
99103

100-
/** Discovers plugins available on the classpath. */
104+
/**
105+
* Adds all plugins discovered by the attached {@link PluginFinder} to
106+
* this index, or does nothing if the attached PluginFiner is null.
107+
*/
101108
public void discover() {
109+
if (pluginFinder == null) return;
102110
final ArrayList<PluginInfo<?>> plugins = new ArrayList<PluginInfo<?>>();
103111
exceptions = pluginFinder.findPlugins(plugins);
104112
addAll(plugins);

0 commit comments

Comments
 (0)