CSVRow { public Integer parseInt(T csvColumn) { String value = parse(csvColumn); if (hasNullValue(value)) { return null; } return Integer.valueOf(value); } CSVRow(ImmutableMap<String, String> lineByHeader); boolean hasEntry(T csvColumn); String parse(T csvColumn); Integer parseInt(T csvColumn); Double parseDouble(T csvColumn); BigDecimal parseBigDecimal(T csvColumn); @Nullable Boolean parseBoolean(T csvColumn); E parseEnum(T csvColumn, Class<E> enumClass); final ImmutableMap<String, String> lineByHeader; }
@Test void testParseInt() { Assertions.assertEquals(1, (int) FULL_ROW.parseInt(TestCSVColumn.INTEGER)); }
@Test void testParseMissingInt() { Assertions.assertNull(EMPTY_ROW.parseInt(TestCSVColumn.INTEGER)); }
@Test void testParseIncorrectInt() { Assertions.assertThrows(NumberFormatException.class, () -> INCORRECT_ROW.parseInt(TestCSVColumn.INTEGER)); }