@Test public void testToData() { assertEquals("SE", EnumHelper.toData(Country.SWEDEN)); assertEquals(1, EnumHelper.toData(Gender.FEMALE)); }
public static Object toData(Enum<?> enumClass) { if (enumClass == null) { return null; } try { Method method = enumClass.getClass().getMethod("toData"); return method.invoke(enumClass); } catch (Exception e) { throw new IllegalArgumentException("Enum '" + enumClass.getClass().getSimpleName() + "' can not be converted to value", e); } }
EnumHelper { public static Object toData(Enum<?> enumClass) { if (enumClass == null) { return null; } try { Method method = enumClass.getClass().getMethod("toData"); return method.invoke(enumClass); } catch (Exception e) { throw new IllegalArgumentException("Enum '" + enumClass.getClass().getSimpleName() + "' can not be converted to value", e); } } }
EnumHelper { public static Object toData(Enum<?> enumClass) { if (enumClass == null) { return null; } try { Method method = enumClass.getClass().getMethod("toData"); return method.invoke(enumClass); } catch (Exception e) { throw new IllegalArgumentException("Enum '" + enumClass.getClass().getSimpleName() + "' can not be converted to value", e); } }  }
EnumHelper { public static Object toData(Enum<?> enumClass) { if (enumClass == null) { return null; } try { Method method = enumClass.getClass().getMethod("toData"); return method.invoke(enumClass); } catch (Exception e) { throw new IllegalArgumentException("Enum '" + enumClass.getClass().getSimpleName() + "' can not be converted to value", e); } }  static Enum<T> toEnum(Class<T> enumClass,
			Object value); static Object toData(Enum<?> enumClass); static boolean isIdentifierAttributeOfTypeString(Class<? extends Enum<?>> enumClass); }
EnumHelper { public static Object toData(Enum<?> enumClass) { if (enumClass == null) { return null; } try { Method method = enumClass.getClass().getMethod("toData"); return method.invoke(enumClass); } catch (Exception e) { throw new IllegalArgumentException("Enum '" + enumClass.getClass().getSimpleName() + "' can not be converted to value", e); } }  static Enum<T> toEnum(Class<T> enumClass,
			Object value); static Object toData(Enum<?> enumClass); static boolean isIdentifierAttributeOfTypeString(Class<? extends Enum<?>> enumClass);  }