@Test public void testConvert_Nulls() { ConversionContext ctx = new ConversionContext.Builder(TypeLiteral.of(RoundingMode.class)).build(); assertThat(testConverter.convert(null, ctx)).isNull(); }
@Override public T convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), "<enumValue>"); try { return (T) factory.invoke(null, value); } catch (InvocationTargetException | IllegalAccessException e) { LOG.log(Level.FINEST, "Invalid enum createValue '" + value + "' for " + enumType.getName(), e); } try { if (value != null) { return (T) factory.invoke(null, value.toUpperCase(Locale.ENGLISH)); } } catch (InvocationTargetException | IllegalAccessException e) { LOG.log(Level.FINEST, "Invalid enum createValue '" + value + "' for " + enumType.getName(), e); } return null; }
EnumConverter implements PropertyConverter<T> { @Override public T convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), "<enumValue>"); try { return (T) factory.invoke(null, value); } catch (InvocationTargetException | IllegalAccessException e) { LOG.log(Level.FINEST, "Invalid enum createValue '" + value + "' for " + enumType.getName(), e); } try { if (value != null) { return (T) factory.invoke(null, value.toUpperCase(Locale.ENGLISH)); } } catch (InvocationTargetException | IllegalAccessException e) { LOG.log(Level.FINEST, "Invalid enum createValue '" + value + "' for " + enumType.getName(), e); } return null; } }
EnumConverter implements PropertyConverter<T> { @Override public T convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), "<enumValue>"); try { return (T) factory.invoke(null, value); } catch (InvocationTargetException | IllegalAccessException e) { LOG.log(Level.FINEST, "Invalid enum createValue '" + value + "' for " + enumType.getName(), e); } try { if (value != null) { return (T) factory.invoke(null, value.toUpperCase(Locale.ENGLISH)); } } catch (InvocationTargetException | IllegalAccessException e) { LOG.log(Level.FINEST, "Invalid enum createValue '" + value + "' for " + enumType.getName(), e); } return null; } EnumConverter(Class<T> enumType); }
EnumConverter implements PropertyConverter<T> { @Override public T convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), "<enumValue>"); try { return (T) factory.invoke(null, value); } catch (InvocationTargetException | IllegalAccessException e) { LOG.log(Level.FINEST, "Invalid enum createValue '" + value + "' for " + enumType.getName(), e); } try { if (value != null) { return (T) factory.invoke(null, value.toUpperCase(Locale.ENGLISH)); } } catch (InvocationTargetException | IllegalAccessException e) { LOG.log(Level.FINEST, "Invalid enum createValue '" + value + "' for " + enumType.getName(), e); } return null; } EnumConverter(Class<T> enumType); @Override T convert(String value, ConversionContext ctx); @Override boolean equals(Object o); @Override int hashCode(); }
EnumConverter implements PropertyConverter<T> { @Override public T convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), "<enumValue>"); try { return (T) factory.invoke(null, value); } catch (InvocationTargetException | IllegalAccessException e) { LOG.log(Level.FINEST, "Invalid enum createValue '" + value + "' for " + enumType.getName(), e); } try { if (value != null) { return (T) factory.invoke(null, value.toUpperCase(Locale.ENGLISH)); } } catch (InvocationTargetException | IllegalAccessException e) { LOG.log(Level.FINEST, "Invalid enum createValue '" + value + "' for " + enumType.getName(), e); } return null; } EnumConverter(Class<T> enumType); @Override T convert(String value, ConversionContext ctx); @Override boolean equals(Object o); @Override int hashCode();  }