File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
src/main/java/org/scijava/module Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 4141import java .util .concurrent .ExecutionException ;
4242import java .util .concurrent .Future ;
4343
44+ import org .scijava .Identifiable ;
4445import org .scijava .MenuPath ;
4546import org .scijava .Priority ;
4647import org .scijava .convert .ConvertService ;
@@ -140,6 +141,17 @@ public List<ModuleInfo> getModules() {
140141 return moduleIndex .getAll ();
141142 }
142143
144+ @ Override
145+ public ModuleInfo getModuleById (final String id ) {
146+ // TODO: Cache identifiers in a hash?
147+ for (final ModuleInfo info : getModules ()) {
148+ if (!(info instanceof Identifiable )) continue ;
149+ final String infoID = ((Identifiable ) info ).getIdentifier ();
150+ if (id .equals (infoID )) return info ;
151+ }
152+ return null ;
153+ }
154+
143155 @ Override
144156 public ModuleInfo getModuleForAccelerator (final Accelerator acc ) {
145157 for (final ModuleInfo info : getModules ()) {
Original file line number Diff line number Diff line change 3636import java .util .Map ;
3737import java .util .concurrent .Future ;
3838
39+ import org .scijava .Identifiable ;
3940import org .scijava .Prioritized ;
4041import org .scijava .input .Accelerator ;
4142import org .scijava .module .process .ModulePostprocessor ;
@@ -90,6 +91,14 @@ public interface ModuleService extends SciJavaService {
9091 /** Gets the list of available modules. */
9192 List <ModuleInfo > getModules ();
9293
94+ /**
95+ * Gets the module with the given identifier string.
96+ *
97+ * @param id The identifier string corresponding to the desired module.
98+ * @return The {@link Identifiable} module with the given identifier.
99+ */
100+ ModuleInfo getModuleById (String id );
101+
93102 /**
94103 * Gets the module for a given keyboard shortcut.
95104 *
You can’t perform that action at this time.
0 commit comments