@Test public void shouldConvertToZeroWhenNull() { assertThat((Integer) converter.convert(null, int.class, bundle), is(equalTo(0))); }
public Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_integer"), value)); } }
PrimitiveIntConverter implements Converter<Integer> { public Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_integer"), value)); } } }
PrimitiveIntConverter implements Converter<Integer> { public Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_integer"), value)); } }  }
PrimitiveIntConverter implements Converter<Integer> { public Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_integer"), value)); } }  Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle); }
PrimitiveIntConverter implements Converter<Integer> { public Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_integer"), value)); } }  Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle);  }