public boolean setAttribute(String name, String value) { if (reqAttribs.containsKey(name)) { reqAttribs.put(name, value); return true; } else if (optAttribs.containsKey(name)) { optAttribs.put(name, value); return true; } return false; }
public Operator(OperatorTemplate opTemplate) { HashMap<String, Attribute> templateAttributes = opTemplate.getAttributes(); reqAttribs = new HashMap<String, String>(); optAttribs = new HashMap<String, String>(); name = opTemplate.getName(); // Sort out the required and optional attributes Iterator<Map.Entry<String, Attribute>> it = templateAttributes.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Attribute> entry = it.next(); // Sort out the attributes into required and optionals if (entry.getValue().required == Attribute.REQUIRED_REQUIRED) { reqAttribs.put(entry.getKey(), null); } else if (entry.getValue().required == Attribute.REQUIRED_OPTIONAL) { optAttribs.put(entry.getKey(), null); } } }