CSVRow { public Double parseDouble(T csvColumn) { String value = parse(csvColumn); if (hasNullValue(value)) { return null; } return Double.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 testParseDouble() { Assertions.assertEquals(2d, (double) FULL_ROW.parseDouble(TestCSVColumn.DOUBLE)); }
@Test void testParseMissingDouble() { Assertions.assertNull(EMPTY_ROW.parseDouble(TestCSVColumn.DOUBLE)); }
@Test void testParseIncorrectDouble() { Assertions.assertThrows(NumberFormatException.class, () -> INCORRECT_ROW.parseDouble(TestCSVColumn.DOUBLE)); }