added superfluous cast as a workaround for the Sun Javac compiler

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@796 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller 2009-03-23 11:30:00 +00:00
parent 303f360d27
commit e6618f050a
1 changed files with 4 additions and 3 deletions

View File

@ -17,18 +17,19 @@ package org.springframework.core.convert.converter;
/**
* Converts a String to a Enum using {@link Enum#valueOf(Class, String)}.
*
*
* @author Keith Donald
* @since 3.0
*/
@SuppressWarnings("unchecked")
public class StringToEnum implements SuperTwoWayConverter<String, Enum> {
public <RT extends Enum> RT convert(String source, Class<RT> targetClass) throws Exception {
return Enum.valueOf(targetClass, source);
return (RT) Enum.valueOf(targetClass, source);
}
public <RS extends String> RS convertBack(Enum target, Class<RS> sourceClass) throws Exception {
return (RS) target.name();
}
}
}