AutomaticStringEnumTypeConverter implements TypeConverter<String, Enum> { @Override public boolean canConvert(Type realToType, Type realDomainType) { Class<?> toType = TypeUtil.getRawClass(realToType); Class<?> domainType = TypeUtil.getRawClass(realDomainType); return String.class.isAssignableFrom(toType) && Enum.class.isAssignableFrom(domainType); }  @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 testCanConvert() throws Exception { assertThat(enumTypeConverter.canConvert(String.class, Gender.class)).isTrue(); assertThat(enumTypeConverter.canConvert(Object.class, Gender.class)).isFalse(); assertThat(enumTypeConverter.canConvert(String.class, String.class)).isFalse(); assertThat(enumTypeConverter.canConvert(Gender.class, String.class)).isFalse(); }