@Test public void testWitClassContainingPrimitiveFields() { List<ClassWithPrimitiveFields> objects = FlexibleCsvReader.readAll( getCsv("ClassWithPrimitiveFields/unexsiting_A_B.csv"), ClassWithPrimitiveFields.class, true, true, false, false); assertEquals(Collections.singletonList(new ClassWithPrimitiveFields(2, 3)), objects); TestUtils.verifyThrow(FlexibleCsvReader.InvalidContent.class, ()-> FlexibleCsvReader.readAll(getCsv("ClassWithPrimitiveFields/unexsiting_A_B.csv"), ClassWithPrimitiveFields.class, true, false, false, false)); objects = FlexibleCsvReader.readAll(getCsv("ClassWithPrimitiveFields/A.csv"), ClassWithPrimitiveFields.class, true, false, true, false); assertEquals(Arrays.asList(new ClassWithPrimitiveFields(1, 0), new ClassWithPrimitiveFields(2, 0)), objects); TestUtils.verifyThrow(FlexibleCsvReader.InvalidContent.class, ()-> FlexibleCsvReader.readAll(getCsv("ClassWithPrimitiveFields/A.csv"), ClassWithPrimitiveFields.class, true, false, false, false)); objects = FlexibleCsvReader.readAll(getCsv("ClassWithPrimitiveFields/A__withEmptyLines.csv"), ClassWithPrimitiveFields.class, true, false, true, true); assertEquals(Arrays.asList(new ClassWithPrimitiveFields(1, 0), new ClassWithPrimitiveFields(2, 0)), objects); TestUtils.verifyThrow(FlexibleCsvReader.InvalidContent.class, ()-> FlexibleCsvReader.readAll(getCsv("ClassWithPrimitiveFields/A__withEmptyLines.csv"), ClassWithPrimitiveFields.class, true, false, true, false)); TestUtils.verifyThrow(FlexibleCsvReader.InvalidContent.class, ()-> FlexibleCsvReader.readAll(getCsv("ClassWithPrimitiveFields/A__withBadType.csv"), ClassWithPrimitiveFields.class, true, true, true, true)); TestUtils.verifyThrow(FlexibleCsvReader.InvalidContent.class, ()-> FlexibleCsvReader.readAll(getCsv("ClassWithPrimitiveFields/A__withStringRepresentingNull.csv"), ClassWithPrimitiveFields.class, true, false, true, true, ";", "NA")); }
public List<T> readAll() { List<T> result = new LinkedList<>(); T obj; while ((obj = parseNextRow()) != null) result.add(obj); return result; }
FlexibleCsvReader implements Closeable { public List<T> readAll() { List<T> result = new LinkedList<>(); T obj; while ((obj = parseNextRow()) != null) result.add(obj); return result; } }
FlexibleCsvReader implements Closeable { public List<T> readAll() { List<T> result = new LinkedList<>(); T obj; while ((obj = parseNextRow()) != null) result.add(obj); return result; } FlexibleCsvReader(Path csv, boolean useExcelFormat, Class<T> rowObjectClass,
                             boolean ignoreUnmatchedColumnTitles, boolean ignoreUnmatchedFields,
                             boolean skipEmptyRows);  FlexibleCsvReader(Path csv, Class<T> rowObjectClass, boolean useExcelFormat, boolean ignoreUnmatchedColumnTitles,
                             boolean ignoreUnmatchedFields, String separator, boolean skipEmptyRows,
                             @Nullable String stringRepresentingNull); }
FlexibleCsvReader implements Closeable { public List<T> readAll() { List<T> result = new LinkedList<>(); T obj; while ((obj = parseNextRow()) != null) result.add(obj); return result; } FlexibleCsvReader(Path csv, boolean useExcelFormat, Class<T> rowObjectClass,
                             boolean ignoreUnmatchedColumnTitles, boolean ignoreUnmatchedFields,
                             boolean skipEmptyRows);  FlexibleCsvReader(Path csv, Class<T> rowObjectClass, boolean useExcelFormat, boolean ignoreUnmatchedColumnTitles,
                             boolean ignoreUnmatchedFields, String separator, boolean skipEmptyRows,
                             @Nullable String stringRepresentingNull); @Nullable T parseNextRow(); List<T> readAll(); @Override void close(); static List<T> readAll(Path csv, Class<T> rowObjectClass,
                                      boolean useExcelFormat, boolean ignoreUnmatchedColumnTitles,
                                      boolean ignoreUnmatchedFields, boolean skipEmptyRows); static List<T> readAll(Path csv, Class<T> rowObjectClass, boolean useExcelFormat, boolean ignoreUnmatchedColumnTitles,
                                      boolean ignoreUnmatchedFields, boolean skipEmptyRows, String separator,
                                      @Nullable String stringRepresentingNull); }
FlexibleCsvReader implements Closeable { public List<T> readAll() { List<T> result = new LinkedList<>(); T obj; while ((obj = parseNextRow()) != null) result.add(obj); return result; } FlexibleCsvReader(Path csv, boolean useExcelFormat, Class<T> rowObjectClass,
                             boolean ignoreUnmatchedColumnTitles, boolean ignoreUnmatchedFields,
                             boolean skipEmptyRows);  FlexibleCsvReader(Path csv, Class<T> rowObjectClass, boolean useExcelFormat, boolean ignoreUnmatchedColumnTitles,
                             boolean ignoreUnmatchedFields, String separator, boolean skipEmptyRows,
                             @Nullable String stringRepresentingNull); @Nullable T parseNextRow(); List<T> readAll(); @Override void close(); static List<T> readAll(Path csv, Class<T> rowObjectClass,
                                      boolean useExcelFormat, boolean ignoreUnmatchedColumnTitles,
                                      boolean ignoreUnmatchedFields, boolean skipEmptyRows); static List<T> readAll(Path csv, Class<T> rowObjectClass, boolean useExcelFormat, boolean ignoreUnmatchedColumnTitles,
                                      boolean ignoreUnmatchedFields, boolean skipEmptyRows, String separator,
                                      @Nullable String stringRepresentingNull);  }