Skip to content

Instantly share code, notes, and snippets.

@csadilek
Created August 12, 2013 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csadilek/6213766 to your computer and use it in GitHub Desktop.
Save csadilek/6213766 to your computer and use it in GitHub Desktop.
public class EnumConverter implements Converter<Enum<?>, String>{
Class enumType;
public EnumConverter(Class enumType) {
this.enumType = enumType;
}
@Override
public Enum<?> toModelValue(String widgetValue) {
return Enum.valueOf(enumType, widgetValue);
}
@Override
public String toWidgetValue(Enum<?> modelValue) {
return modelValue.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment