restructured code

This commit is contained in:
jomu
2013-03-03 03:48:25 +00:00
parent af671d3c7c
commit 75d060ec24

View File

@ -24,8 +24,8 @@ public class DefaultConfiguration<T, V extends T> implements Configuration<T, V>
* creates a new instance of a configuration
*/
public DefaultConfiguration() {
parameterMap = new HashMap<Parameter<T>, V>();
parameterNameMap = new HashMap<String, Parameter<T>>();
parameterMap = new HashMap<>();
parameterNameMap = new HashMap<>();
}
/**
@ -60,7 +60,7 @@ public class DefaultConfiguration<T, V extends T> implements Configuration<T, V>
*/
@Override
public void validateConfiguration() throws ConfigurationException {
List<Parameter> missingMandatoryParameters = new LinkedList<Parameter>();
List<Parameter> missingMandatoryParameters = new LinkedList<>();
for (Parameter p : parameterMap.keySet()) {
if ((!validateParameter(p)) && (!missingMandatoryParameters.contains(p))) {
missingMandatoryParameters.add(p);
@ -88,6 +88,22 @@ public class DefaultConfiguration<T, V extends T> implements Configuration<T, V>
}
}
/**
* overrides parameter map with given map
*
* @param map map to use
* @throws ConfigurationException if the parameter is not defined
*/
public void setParameterValue (Map<Parameter<T>, V> map) throws ConfigurationException {
for ( Parameter<T> key : map.keySet()) {
if (parameterMap.containsKey(key)) {
parameterMap.put (key, map.get(key));
} else {
throw new ConfigurationException("Parameter " + key.getName() + " not defined");
}
}
}
/**
* sets the value of parameter with given name
*