From ed6adc706e0c0b64314547b720cdab4a70d99b3f Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Mon, 13 Jun 2016 02:29:53 +0000 Subject: [PATCH] Use generics diamonds. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1748079 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/commons/csv/CSVFormat.java | 2 +- src/main/java/org/apache/commons/csv/CSVParser.java | 6 +++--- .../java/org/apache/commons/csv/CSVFileParserTest.java | 2 +- src/test/java/org/apache/commons/csv/CSVParserTest.java | 2 +- src/test/java/org/apache/commons/csv/CSVPrinterTest.java | 8 ++++---- src/test/java/org/apache/commons/csv/CSVRecordTest.java | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java index 4a0d5528..844dd558 100644 --- a/src/main/java/org/apache/commons/csv/CSVFormat.java +++ b/src/main/java/org/apache/commons/csv/CSVFormat.java @@ -1215,7 +1215,7 @@ public final class CSVFormat implements Serializable { // validate header if (header != null) { - final Set dupCheck = new HashSet(); + final Set dupCheck = new HashSet<>(); for (final String hdr : header) { if (!dupCheck.add(hdr)) { throw new IllegalArgumentException( diff --git a/src/main/java/org/apache/commons/csv/CSVParser.java b/src/main/java/org/apache/commons/csv/CSVParser.java index 07ad6ffe..dc1684c2 100644 --- a/src/main/java/org/apache/commons/csv/CSVParser.java +++ b/src/main/java/org/apache/commons/csv/CSVParser.java @@ -216,7 +216,7 @@ public final class CSVParser implements Iterable, Closeable { private final Lexer lexer; /** A record buffer for getRecord(). Grows as necessary and is reused. */ - private final List record = new ArrayList(); + private final List record = new ArrayList<>(); /** * The next record number to assign. @@ -331,7 +331,7 @@ public final class CSVParser implements Iterable, Closeable { * @return a copy of the header map that iterates in column order. */ public Map getHeaderMap() { - return this.headerMap == null ? null : new LinkedHashMap(this.headerMap); + return this.headerMap == null ? null : new LinkedHashMap<>(this.headerMap); } /** @@ -362,7 +362,7 @@ public final class CSVParser implements Iterable, Closeable { */ public List getRecords() throws IOException { CSVRecord rec; - final List records = new ArrayList(); + final List records = new ArrayList<>(); while ((rec = this.nextRecord()) != null) { records.add(rec); } diff --git a/src/test/java/org/apache/commons/csv/CSVFileParserTest.java b/src/test/java/org/apache/commons/csv/CSVFileParserTest.java index 10420303..850f3b12 100644 --- a/src/test/java/org/apache/commons/csv/CSVFileParserTest.java +++ b/src/test/java/org/apache/commons/csv/CSVFileParserTest.java @@ -69,7 +69,7 @@ public class CSVFileParserTest { @Parameters public static Collection generateData() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); final FilenameFilter filenameFilter = new FilenameFilter() { diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java b/src/test/java/org/apache/commons/csv/CSVParserTest.java index 1c68867c..c8257500 100644 --- a/src/test/java/org/apache/commons/csv/CSVParserTest.java +++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java @@ -393,7 +393,7 @@ public class CSVParserTest { @Test public void testForEach() throws Exception { - final List records = new ArrayList(); + final List records = new ArrayList<>(); final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z"); diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java index 4982514e..0f461b56 100644 --- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java +++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java @@ -495,7 +495,7 @@ public class CSVPrinterTest { final CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\'); final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, format); - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.add("\""); printer.printRecord(list); printer.close(); @@ -511,7 +511,7 @@ public class CSVPrinterTest { final CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\'); final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, format); - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.add("\n"); printer.printRecord(list); printer.close(); @@ -527,7 +527,7 @@ public class CSVPrinterTest { final CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\'); final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, format); - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.add("\\"); printer.printRecord(list); printer.close(); @@ -543,7 +543,7 @@ public class CSVPrinterTest { final CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\'); final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, format); - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.add("\""); list.add("\n"); list.add("\\"); diff --git a/src/test/java/org/apache/commons/csv/CSVRecordTest.java b/src/test/java/org/apache/commons/csv/CSVRecordTest.java index e3f18814..aa488423 100644 --- a/src/test/java/org/apache/commons/csv/CSVRecordTest.java +++ b/src/test/java/org/apache/commons/csv/CSVRecordTest.java @@ -46,7 +46,7 @@ public class CSVRecordTest { public void setUp() throws Exception { values = new String[] { "A", "B", "C" }; record = new CSVRecord(values, null, null, 0, -1); - header = new HashMap(); + header = new HashMap<>(); header.put("first", Integer.valueOf(0)); header.put("second", Integer.valueOf(1)); header.put("third", Integer.valueOf(2)); @@ -132,7 +132,7 @@ public class CSVRecordTest { @Test public void testPutInMap() { - final Map map = new ConcurrentHashMap(); + final Map map = new ConcurrentHashMap<>(); this.recordWithHeader.putIn(map); this.validateMap(map, false); // Test that we can compile with assigment to the same map as the param. @@ -148,7 +148,7 @@ public class CSVRecordTest { map.remove("OldColumn"); map.put("ZColumn", "NewValue"); // check: - final ArrayList list = new ArrayList(map.values()); + final ArrayList list = new ArrayList<>(map.values()); Collections.sort(list); printer.printRecord(list); Assert.assertEquals("A,B,C,NewValue" + CSVFormat.DEFAULT.getRecordSeparator(), printer.getOut().toString());