@Test public void shouldBeAbleToConvertByOrdinal() { assertThat(converter.convert("1", MyCustomEnum.class, bundle), is(equalTo(MyCustomEnum.SECOND))); }
@SuppressWarnings("unchecked") public T convert(String value, Class<? extends T> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return null; } if (Character.isDigit(value.charAt(0))) { return resolveByOrdinal(value, (Class<T>) type, bundle); } else { return resolveByName(value, (Class<T>) type, bundle); } }
EnumConverter implements Converter<T> { @SuppressWarnings("unchecked") public T convert(String value, Class<? extends T> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return null; } if (Character.isDigit(value.charAt(0))) { return resolveByOrdinal(value, (Class<T>) type, bundle); } else { return resolveByName(value, (Class<T>) type, bundle); } } }
EnumConverter implements Converter<T> { @SuppressWarnings("unchecked") public T convert(String value, Class<? extends T> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return null; } if (Character.isDigit(value.charAt(0))) { return resolveByOrdinal(value, (Class<T>) type, bundle); } else { return resolveByName(value, (Class<T>) type, bundle); } }  }
EnumConverter implements Converter<T> { @SuppressWarnings("unchecked") public T convert(String value, Class<? extends T> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return null; } if (Character.isDigit(value.charAt(0))) { return resolveByOrdinal(value, (Class<T>) type, bundle); } else { return resolveByName(value, (Class<T>) type, bundle); } }  @SuppressWarnings("unchecked") T convert(String value, Class<? extends T> type, ResourceBundle bundle); }
EnumConverter implements Converter<T> { @SuppressWarnings("unchecked") public T convert(String value, Class<? extends T> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return null; } if (Character.isDigit(value.charAt(0))) { return resolveByOrdinal(value, (Class<T>) type, bundle); } else { return resolveByName(value, (Class<T>) type, bundle); } }  @SuppressWarnings("unchecked") T convert(String value, Class<? extends T> type, ResourceBundle bundle);  }