fixed sonar bugs

This commit is contained in:
jomu
2015-02-21 15:37:23 +00:00
parent cd2f3eb7b4
commit 0da3928f8a
4 changed files with 17 additions and 3 deletions

View File

@ -25,5 +25,12 @@
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -33,9 +33,11 @@ public class DefaultConfiguration<T, V extends T> implements Configuration<T, V>
* *
* @return the map of parameters and values * @return the map of parameters and values
*/ */
/*
protected Map<Parameter<T>, V> getParameterMap() { protected Map<Parameter<T>, V> getParameterMap() {
return parameterMap; return parameterMap;
} }
*/
/** /**
* adds a new parameter to the configuration * adds a new parameter to the configuration
@ -95,9 +97,11 @@ public class DefaultConfiguration<T, V extends T> implements Configuration<T, V>
* @throws ConfigurationException if the parameter is not defined * @throws ConfigurationException if the parameter is not defined
*/ */
public void setParameterValue (Map<Parameter<T>, V> map) throws ConfigurationException { public void setParameterValue (Map<Parameter<T>, V> map) throws ConfigurationException {
for ( Parameter<T> key : map.keySet()) { for ( Map.Entry<Parameter<T>,V> entry : map.entrySet()) {
Parameter<T> key = entry.getKey();
V value = entry.getValue();
if (parameterMap.containsKey(key)) { if (parameterMap.containsKey(key)) {
parameterMap.put (key, map.get(key)); parameterMap.put (key, value);
} else { } else {
throw new ConfigurationException("Parameter " + key.getName() + " not defined"); throw new ConfigurationException("Parameter " + key.getName() + " not defined");
} }

View File

@ -2,6 +2,7 @@ package de.muehlencord.shared.configuration;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* *
@ -9,6 +10,8 @@ import java.util.List;
* @author jomu * @author jomu
*/ */
public abstract class Parameter<T> { public abstract class Parameter<T> {
private final static Logger LOGGER = Logger.getLogger(Parameter.class);
/** the name of the parameter */ /** the name of the parameter */
private String name; private String name;
@ -133,6 +136,7 @@ public abstract class Parameter<T> {
validator.validate(value); validator.validate(value);
return true; return true;
} catch (ValidationException ex) { } catch (ValidationException ex) {
LOGGER.debug (ex.toString(), ex);
return false; return false;
} }
} }

View File

@ -2,7 +2,6 @@ package de.muehlencord.shared.configuration.validator;
import de.muehlencord.shared.configuration.ValidationException; import de.muehlencord.shared.configuration.ValidationException;
import de.muehlencord.shared.configuration.Validator; import de.muehlencord.shared.configuration.Validator;
import java.util.Arrays;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;