EnumConverter implements ITypeConverter<E> { @Override public E convert(String value) { try { return E.valueOf(enumType, value); } catch(Exception e) { throw new RuntimeException(e); } } EnumConverter(Class<E> enumType); @Override E convert(String value); @Override Type getTargetType(); @Override String toString();  }
@Test public void testConvert() throws Exception { EnumConverter<SampleEnum> converter = new EnumConverter<>(SampleEnum.class); Assert.assertEquals(SampleEnum.Bike, converter.convert("Bike")); Assert.assertEquals(SampleEnum.Car, converter.convert("Car")); JUnitUtils.assertThrows(() -> converter.convert("Plane")); }