restructured code
This commit is contained in:
@ -24,8 +24,8 @@ public class DefaultConfiguration<T, V extends T> implements Configuration<T, V>
|
|||||||
* creates a new instance of a configuration
|
* creates a new instance of a configuration
|
||||||
*/
|
*/
|
||||||
public DefaultConfiguration() {
|
public DefaultConfiguration() {
|
||||||
parameterMap = new HashMap<Parameter<T>, V>();
|
parameterMap = new HashMap<>();
|
||||||
parameterNameMap = new HashMap<String, Parameter<T>>();
|
parameterNameMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +60,7 @@ public class DefaultConfiguration<T, V extends T> implements Configuration<T, V>
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void validateConfiguration() throws ConfigurationException {
|
public void validateConfiguration() throws ConfigurationException {
|
||||||
List<Parameter> missingMandatoryParameters = new LinkedList<Parameter>();
|
List<Parameter> missingMandatoryParameters = new LinkedList<>();
|
||||||
for (Parameter p : parameterMap.keySet()) {
|
for (Parameter p : parameterMap.keySet()) {
|
||||||
if ((!validateParameter(p)) && (!missingMandatoryParameters.contains(p))) {
|
if ((!validateParameter(p)) && (!missingMandatoryParameters.contains(p))) {
|
||||||
missingMandatoryParameters.add(p);
|
missingMandatoryParameters.add(p);
|
||||||
@ -87,6 +87,22 @@ public class DefaultConfiguration<T, V extends T> implements Configuration<T, V>
|
|||||||
throw new ConfigurationException("Parameter " + p.getName() + " not defined");
|
throw new ConfigurationException("Parameter " + p.getName() + " not defined");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* sets the value of parameter with given name
|
||||||
|
|||||||
Reference in New Issue
Block a user