/** Sets the given module's input values to those in the given map. */
  private void assignInputs(final Module module, final Map<String, Object> inputMap) {
    if (inputMap == null) return; // no inputs to assign

    for (final String name : inputMap.keySet()) {
      final ModuleItem<?> input = module.getInfo().getInput(name);
      if (input == null) {
        log.error("No such input: " + name);
        continue;
      }
      final Object value = inputMap.get(name);
      final Class<?> type = input.getType();
      final Object converted = ConversionUtils.convert(value, type);
      if (value != null && converted == null) {
        log.error(
            "For input "
                + name
                + ": incompatible object "
                + value.getClass().getName()
                + " for type "
                + type.getName());
        continue;
      }
      module.setInput(name, converted);
      module.setResolved(name, true);
    }
  }
 private <T> ModuleItem<T> getSingleItem(
     final Module module, final Class<T> type, final Iterable<ModuleItem<?>> items) {
   ModuleItem<T> result = null;
   for (final ModuleItem<?> item : items) {
     final String name = item.getName();
     final boolean resolved = module.isResolved(name);
     if (resolved) continue; // skip resolved inputs
     if (!type.isAssignableFrom(item.getType())) continue;
     if (result != null) return null; // multiple matching items
     @SuppressWarnings("unchecked")
     final ModuleItem<T> typedItem = (ModuleItem<T>) item;
     result = typedItem;
   }
   return result;
 }
 public void addModule(Module g, File f) {
   ModuleItem b = new ModuleItem(g);
   b.setFileName(f);
   p2.add(b);
   CopyOfModuleListWindow.this.validate();
 }
 public Module getModule() {
   return selected.getModule();
 }
 @Override
 public void removeOutput(final ModuleItem<?> output) {
   outputMap().remove(output.getName());
   outputList().remove(output);
 }
 @Override
 public void removeInput(final ModuleItem<?> input) {
   inputMap().remove(input.getName());
   inputList().remove(input);
 }
 @Override
 public void addOutput(final ModuleItem<?> output) {
   outputMap().put(output.getName(), output);
   outputList().add(output);
 }
 @Override
 public void addInput(final ModuleItem<?> input) {
   inputMap().put(input.getName(), input);
   inputList().add(input);
 }