@Test public void testIsIdentifierAttributeOfTypeString() { assertTrue(EnumHelper.isIdentifierAttributeOfTypeString(Country.class)); assertFalse(EnumHelper.isIdentifierAttributeOfTypeString(Gender.class)); }
public static boolean isIdentifierAttributeOfTypeString(Class<? extends Enum<?>> enumClass) { if (enumClass == null) { return false; } try { Method[] methods = enumClass.getMethods(); for (Method method : methods) { if (method.getName().startsWith("from") && method.getReturnType().equals(enumClass)) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0].equals(String.class)) { return true; } } } return false; } catch (Exception e) { throw new IllegalArgumentException("Enum '" + enumClass.getClass().getSimpleName() + "' can not examined for identifier attribute type", e); } }
EnumHelper { public static boolean isIdentifierAttributeOfTypeString(Class<? extends Enum<?>> enumClass) { if (enumClass == null) { return false; } try { Method[] methods = enumClass.getMethods(); for (Method method : methods) { if (method.getName().startsWith("from") && method.getReturnType().equals(enumClass)) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0].equals(String.class)) { return true; } } } return false; } catch (Exception e) { throw new IllegalArgumentException("Enum '" + enumClass.getClass().getSimpleName() + "' can not examined for identifier attribute type", e); } } }
EnumHelper { public static boolean isIdentifierAttributeOfTypeString(Class<? extends Enum<?>> enumClass) { if (enumClass == null) { return false; } try { Method[] methods = enumClass.getMethods(); for (Method method : methods) { if (method.getName().startsWith("from") && method.getReturnType().equals(enumClass)) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0].equals(String.class)) { return true; } } } return false; } catch (Exception e) { throw new IllegalArgumentException("Enum '" + enumClass.getClass().getSimpleName() + "' can not examined for identifier attribute type", e); } }  }
EnumHelper { public static boolean isIdentifierAttributeOfTypeString(Class<? extends Enum<?>> enumClass) { if (enumClass == null) { return false; } try { Method[] methods = enumClass.getMethods(); for (Method method : methods) { if (method.getName().startsWith("from") && method.getReturnType().equals(enumClass)) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0].equals(String.class)) { return true; } } } return false; } catch (Exception e) { throw new IllegalArgumentException("Enum '" + enumClass.getClass().getSimpleName() + "' can not examined for identifier attribute type", 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 boolean isIdentifierAttributeOfTypeString(Class<? extends Enum<?>> enumClass) { if (enumClass == null) { return false; } try { Method[] methods = enumClass.getMethods(); for (Method method : methods) { if (method.getName().startsWith("from") && method.getReturnType().equals(enumClass)) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0].equals(String.class)) { return true; } } } return false; } catch (Exception e) { throw new IllegalArgumentException("Enum '" + enumClass.getClass().getSimpleName() + "' can not examined for identifier attribute type", e); } }  static Enum<T> toEnum(Class<T> enumClass,
			Object value); static Object toData(Enum<?> enumClass); static boolean isIdentifierAttributeOfTypeString(Class<? extends Enum<?>> enumClass);  }