polish
This commit is contained in:
@@ -27,14 +27,16 @@ import org.springframework.core.convert.converter.Converter;
|
||||
class StringToBooleanConverter implements Converter<String, Boolean> {
|
||||
|
||||
public Boolean convert(String source) {
|
||||
if (source.equals("true")) {
|
||||
if (source.equals("")) {
|
||||
return null;
|
||||
} else if (source.equals("true")) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
else if (source.equals("false")) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Invalid boolean string '" + source + "'; expected 'true' or 'false'");
|
||||
throw new IllegalArgumentException("Invalid boolean string '" + source + "'; expected \"\", 'true', or 'false'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,9 @@ class StringToNumberConverterFactory implements ConverterFactory<String, Number>
|
||||
}
|
||||
|
||||
public T convert(String source) {
|
||||
if ("".equals(source)) {
|
||||
return null;
|
||||
}
|
||||
return NumberUtils.parseNumber(source, targetType);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user