More lambdas, less boilerplate.
This commit is contained in:
parent
2f1ac70815
commit
dfd58d8a94
|
@ -69,13 +69,7 @@ public class CSVFileParserTest {
|
|||
public static Collection<Object[]> generateData() {
|
||||
final List<Object[]> list = new ArrayList<>();
|
||||
|
||||
final FilenameFilter fileNameFilter = new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(final File dir, final String name) {
|
||||
return name.startsWith("test") && name.endsWith(".txt");
|
||||
}
|
||||
};
|
||||
final FilenameFilter fileNameFilter = (dir, name) -> name.startsWith("test") && name.endsWith(".txt");
|
||||
final File[] files = BASE.listFiles(fileNameFilter);
|
||||
if (files != null) {
|
||||
for (final File f : files) {
|
||||
|
|
|
@ -240,45 +240,25 @@ public class PerformanceTest {
|
|||
show();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private static interface CSVParserFactory {
|
||||
public CSVParser createParser() throws IOException;
|
||||
}
|
||||
|
||||
private static void testParseCommonsCSV() throws Exception {
|
||||
testParser("CSV", new CSVParserFactory() {
|
||||
@Override
|
||||
public CSVParser createParser() throws IOException {
|
||||
return new CSVParser(createReader(), format);
|
||||
}
|
||||
});
|
||||
testParser("CSV", () -> new CSVParser(createReader(), format));
|
||||
}
|
||||
|
||||
private static void testParsePath() throws Exception {
|
||||
testParser("CSV-PATH", new CSVParserFactory() {
|
||||
@Override
|
||||
public CSVParser createParser() throws IOException {
|
||||
return CSVParser.parse(Files.newInputStream(Paths.get(BIG_FILE.toURI())), StandardCharsets.ISO_8859_1, format);
|
||||
}
|
||||
});
|
||||
testParser("CSV-PATH", () -> CSVParser.parse(Files.newInputStream(Paths.get(BIG_FILE.toURI())), StandardCharsets.ISO_8859_1, format));
|
||||
}
|
||||
|
||||
private static void testParsePathDoubleBuffering() throws Exception {
|
||||
testParser("CSV-PATH-DB", new CSVParserFactory() {
|
||||
@Override
|
||||
public CSVParser createParser() throws IOException {
|
||||
return CSVParser.parse(Files.newBufferedReader(Paths.get(BIG_FILE.toURI()), StandardCharsets.ISO_8859_1), format);
|
||||
}
|
||||
});
|
||||
testParser("CSV-PATH-DB", () -> CSVParser.parse(Files.newBufferedReader(Paths.get(BIG_FILE.toURI()), StandardCharsets.ISO_8859_1), format));
|
||||
}
|
||||
|
||||
private static void testParseURL() throws Exception {
|
||||
testParser("CSV-URL", new CSVParserFactory() {
|
||||
@Override
|
||||
public CSVParser createParser() throws IOException {
|
||||
//NOTE: URL will always return a BufferedInputStream.
|
||||
return CSVParser.parse(BIG_FILE.toURI().toURL(), StandardCharsets.ISO_8859_1, format);
|
||||
}
|
||||
});
|
||||
testParser("CSV-URL", () -> CSVParser.parse(BIG_FILE.toURI().toURL(), StandardCharsets.ISO_8859_1, format));
|
||||
}
|
||||
|
||||
private static Constructor<Lexer> getLexerCtor(final String clazz) throws Exception {
|
||||
|
|
Loading…
Reference in New Issue