@Override public int compareTo(Configuration conf) { if (!(conf instanceof ToolConfiguration)) { throw new UnsupportedOperationException("ToolConfigurations can only be compared to other ToolConfigurations"); } ToolConfiguration tool = (ToolConfiguration)conf; if (getKey() == null && tool.getKey() == null) { return 0; } else if (getKey() == null) { return -1; } else if (tool.getKey() == null) { return 1; } else { return getKey().compareTo(tool.getKey()); } }
public ToolConfiguration getTool(String key) { for (ToolConfiguration tool : getTools()) { if (key.equals(tool.getKey())) { return tool; } } return null; }
@Override public void validate() { super.validate(); // make sure the key is not null if (getKey() == null) { throw new NullKeyException(this); } Status status = getStatus(); switch (status) { case VALID: break; default: throw new ConfigurationException(this, getError(status)); } }
if (!name.equals(tool.getKey()))
public ToolInfo createInfo() { ToolInfo info = null; Status status = getStatus(); switch (status) { case VALID: info = new ToolInfo(getKey(), getToolClass()); break; default: throw problem == null ? new ConfigurationException(this, getError(status)) : new ConfigurationException(this, getError(status), problem); } info.restrictTo(getRestrictTo()); if (getSkipSetters() != null) { info.setSkipSetters(getSkipSetters()); } // it's ok to use this here, because we know it's the // first time properties have been added to this ToolInfo Map<String,Object> properties = getPropertyMap(); // make sure key is present in properties, even for default properties properties.put(ToolContext.TOOLKEY_KEY, getKey()); info.addProperties(properties); return info; }