tidying string to char conversion

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1916 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Keith Donald 2009-09-17 20:05:38 +00:00
parent e4c356bd19
commit 99120ebc41
1 changed files with 3 additions and 0 deletions

View File

@ -30,6 +30,9 @@ class StringToCharacterConverter implements Converter<String, Character> {
if ("".equals(source)) {
return null;
}
if (source.length() > 1) {
throw new IllegalArgumentException("Can only convert a [String] with length of 1 to a [Character]; string value '" + source + "' has length of " + source.length());
}
return source.charAt(0);
}