Browse Source

added superfluous cast as a workaround for the Sun Javac compiler

pull/23217/head
Juergen Hoeller 17 years ago
parent
commit
38182f302a
  1. 7
      org.springframework.core/src/main/java/org/springframework/core/convert/converter/StringToEnum.java

7
org.springframework.core/src/main/java/org/springframework/core/convert/converter/StringToEnum.java

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

Loading…
Cancel
Save