/** * Add a starting point to the list * @param definition a BasicDefinition */ public void addDefinition(BasicDefinition definition) { if (_definitions.ContainsKey(definition.getId())) { throw new InvalidOperationException("ERROR: An definition with identifier '" + definition.getId() + "' already exists"); } initDefinition(definition); _definitions[definition.getId()] = definition; }
/** * Initialize a definition. * @param definition a BasicDefinition */ public void initDefinition(BasicDefinition definition) { // parse the values into something that can searched more efficiently if (definition.getInputs() != null) { Dictionary <String, IInput> parsedInputMap = new Dictionary <String, IInput>(); foreach (BasicInput input in definition.getInputs()) { // verify that all inputs contain a key if (input.getKey() == null) { throw new InvalidOperationException("All input defintions must have a 'key' value defined."); } parsedInputMap[input.getKey()] = input; // the parsed input map provides an easy way to look up by key definition.setInputMap(parsedInputMap); } } // store the outputs in a Map that can searched more efficiently if (definition.getOutputs() != null) { Dictionary <String, IOutput> parsedOutputMap = new Dictionary <String, IOutput>(); foreach (BasicOutput output in definition.getOutputs()) { // verify that all inputs contain a key if (output.getKey() == null) { throw new InvalidOperationException("All output definitions must have a 'key' defined."); } parsedOutputMap[output.getKey()] = output; } definition.setOutputMap(parsedOutputMap); } }