AutomaticStringEnumTypeConverter implements TypeConverter<String, Enum> { @Override public Enum convert(String object, SyntheticField domainField, Object domainObject, String... tags) throws JTransfoException { if (null == object || 0 == object.length()) { return null; } return Enum.valueOf((Class<Enum>) domainField.getType(), object); }  @Override boolean canConvert(Type realToType, Type realDomainType); @Override Enum convert(String object, SyntheticField domainField, Object domainObject, String... tags); @Override String reverse(Enum object, SyntheticField toField, Object toObject, String... tags);  }
@Test public void testConvert() throws Exception { assertThat(enumTypeConverter.convert(Gender.MALE.name(), genderField, null)).isEqualTo(Gender.MALE); assertThat(enumTypeConverter.convert(Gender.FEMALE.name(), genderField, null)).isEqualTo(Gender.FEMALE); assertThat(enumTypeConverter.convert(null, genderField, null)).isNull(); assertThat(enumTypeConverter.convert("", genderField, null)).isNull(); exception.expect(IllegalArgumentException.class); assertThat(enumTypeConverter.convert("blabla", genderField, null)); }