You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/11/21 03:09:06 UTC
[commons-csv] branch master updated: Use final.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git
The following commit(s) were added to refs/heads/master by this push:
new 4dc996e Use final.
4dc996e is described below
commit 4dc996e315b2bd3d0fcec04901eac311d546e56c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Nov 20 22:09:00 2020 -0500
Use final.
---
src/main/java/org/apache/commons/csv/CSVFormat.java | 4 ++--
src/test/java/org/apache/commons/csv/CSVFileParserTest.java | 4 ++--
src/test/java/org/apache/commons/csv/CSVFormatTest.java | 12 ++++++------
src/test/java/org/apache/commons/csv/CSVPrinterTest.java | 2 +-
src/test/java/org/apache/commons/csv/CSVRecordTest.java | 4 ++--
.../java/org/apache/commons/csv/issues/JiraCsv149Test.java | 4 ++--
.../java/org/apache/commons/csv/issues/JiraCsv211Test.java | 6 +++---
7 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java
index cd19936..de0fd03 100644
--- a/src/main/java/org/apache/commons/csv/CSVFormat.java
+++ b/src/main/java/org/apache/commons/csv/CSVFormat.java
@@ -875,8 +875,8 @@ public final class CSVFormat implements Serializable {
final StringWriter out = new StringWriter();
try (CSVPrinter csvPrinter = new CSVPrinter(out, this)) {
csvPrinter.printRecord(values);
- String res = out.toString();
- int len = recordSeparator != null ? res.length() - recordSeparator.length() : res.length();
+ final String res = out.toString();
+ final int len = recordSeparator != null ? res.length() - recordSeparator.length() : res.length();
return res.substring(0, len);
} catch (final IOException e) {
// should not happen because a StringWriter does not do IO.
diff --git a/src/test/java/org/apache/commons/csv/CSVFileParserTest.java b/src/test/java/org/apache/commons/csv/CSVFileParserTest.java
index 2628f52..d71007b 100644
--- a/src/test/java/org/apache/commons/csv/CSVFileParserTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVFileParserTest.java
@@ -93,7 +93,7 @@ public class CSVFileParserTest {
try (final CSVParser parser = CSVParser.parse(new File(BASE, split[0]), Charset.defaultCharset(), format)) {
for (final CSVRecord record : parser) {
String parsed = Arrays.toString(record.values());
- String comment = record.getComment();
+ final String comment = record.getComment();
if (checkComments && comment != null) {
parsed += "#" + comment.replace("\n", "\\n");
}
@@ -138,7 +138,7 @@ public class CSVFileParserTest {
try (final CSVParser parser = CSVParser.parse(resource, Charset.forName("UTF-8"), format)) {
for (final CSVRecord record : parser) {
String parsed = Arrays.toString(record.values());
- String comment = record.getComment();
+ final String comment = record.getComment();
if (checkComments && comment != null) {
parsed += "#" + comment.replace("\n", "\\n");
}
diff --git a/src/test/java/org/apache/commons/csv/CSVFormatTest.java b/src/test/java/org/apache/commons/csv/CSVFormatTest.java
index a31875f..ded2ab9 100644
--- a/src/test/java/org/apache/commons/csv/CSVFormatTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVFormatTest.java
@@ -1216,14 +1216,14 @@ public class CSVFormatTest {
@Test
public void testWithHeaderEnumNull() {
final CSVFormat format = CSVFormat.DEFAULT;
- Class<Enum<?>> simpleName = null;
+ final Class<Enum<?>> simpleName = null;
format.withHeader(simpleName);
}
@Test
public void testWithHeaderResultSetNull() throws SQLException {
final CSVFormat format = CSVFormat.DEFAULT;
- ResultSet resultSet = null;
+ final ResultSet resultSet = null;
format.withHeader(resultSet);
}
@@ -1231,7 +1231,7 @@ public class CSVFormatTest {
public void testPrintWithQuoteModeIsNONE() throws IOException {
final Reader in = new StringReader("a,b,c");
final Appendable out = new StringBuilder();
- CSVFormat format = CSVFormat.RFC4180.withDelimiter(',').withQuote('"').withEscape('?').withQuoteMode(QuoteMode.NONE);
+ final CSVFormat format = CSVFormat.RFC4180.withDelimiter(',').withQuote('"').withEscape('?').withQuoteMode(QuoteMode.NONE);
format.print(in, out, true);
assertEquals("a?,b?,c", out.toString());
}
@@ -1240,7 +1240,7 @@ public class CSVFormatTest {
public void testPrintWithQuotes() throws IOException {
final Reader in = new StringReader("\"a,b,c\r\nx,y,z");
final Appendable out = new StringBuilder();
- CSVFormat format = CSVFormat.RFC4180.withDelimiter(',').withQuote('"').withEscape('?').withQuoteMode(QuoteMode.NON_NUMERIC);
+ final CSVFormat format = CSVFormat.RFC4180.withDelimiter(',').withQuote('"').withEscape('?').withQuoteMode(QuoteMode.NON_NUMERIC);
format.print(in, out, true);
assertEquals("\"\"\"\"a,b,c\r\nx,y,z\"", out.toString());
}
@@ -1249,14 +1249,14 @@ public class CSVFormatTest {
public void testPrintWithoutQuotes() throws IOException {
final Reader in = new StringReader("");
final Appendable out = new StringBuilder();
- CSVFormat format = CSVFormat.RFC4180.withDelimiter(',').withQuote('"').withEscape('?').withQuoteMode(QuoteMode.NON_NUMERIC);
+ final CSVFormat format = CSVFormat.RFC4180.withDelimiter(',').withQuote('"').withEscape('?').withQuoteMode(QuoteMode.NON_NUMERIC);
format.print(in, out, true);
assertEquals("\"\"", out.toString());
}
@Test
public void testTrim() throws IOException {
- CSVFormat formatWithTrim = CSVFormat.DEFAULT.withDelimiter(',').withTrim().withQuote(null).withRecordSeparator(CRLF);
+ final CSVFormat formatWithTrim = CSVFormat.DEFAULT.withDelimiter(',').withTrim().withQuote(null).withRecordSeparator(CRLF);
CharSequence in = "a,b,c";
final StringBuilder out = new StringBuilder();
diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
index 7126e9d..8c8f19a 100644
--- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
@@ -1343,7 +1343,7 @@ public class CSVPrinterTest {
final CharArrayWriter charArrayWriter = new CharArrayWriter(0);
try (final CSVParser parser = CSVFormat.DEFAULT.parse(new StringReader(rowData));
CSVPrinter csvPrinter = CSVFormat.INFORMIX_UNLOAD.print(charArrayWriter)) {
- for (CSVRecord record : parser) {
+ for (final CSVRecord record : parser) {
csvPrinter.printRecord(record);
}
}
diff --git a/src/test/java/org/apache/commons/csv/CSVRecordTest.java b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
index deef5c6..11401a0 100644
--- a/src/test/java/org/apache/commons/csv/CSVRecordTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
@@ -51,9 +51,9 @@ public class CSVRecordTest {
SECOND("second"),
THIRD("third");
- private String number;
+ private final String number;
- EnumHeader(String number) {
+ EnumHeader(final String number) {
this.number = number;
}
diff --git a/src/test/java/org/apache/commons/csv/issues/JiraCsv149Test.java b/src/test/java/org/apache/commons/csv/issues/JiraCsv149Test.java
index 83fb36f..38394ba 100644
--- a/src/test/java/org/apache/commons/csv/issues/JiraCsv149Test.java
+++ b/src/test/java/org/apache/commons/csv/issues/JiraCsv149Test.java
@@ -35,7 +35,7 @@ public class JiraCsv149Test {
testJiraCsv149EndWithEolAtEof(true);
}
- private void testJiraCsv149EndWithEolAtEof(boolean eolAtEof) throws IOException {
+ private void testJiraCsv149EndWithEolAtEof(final boolean eolAtEof) throws IOException {
String source = "A,B,C,D" + CR_LF + "a1,b1,c1,d1" + CR_LF + "a2,b2,c2,d2";
if (eolAtEof) {
source += CR_LF;
@@ -44,7 +44,7 @@ public class JiraCsv149Test {
final CSVFormat format = CSVFormat.RFC4180.withFirstRecordAsHeader().withQuote('"');
int lineCounter = 2;
try (final CSVParser parser = new CSVParser(records, format)) {
- for (CSVRecord record : parser) {
+ for (final CSVRecord record : parser) {
assertEquals(lineCounter++, parser.getCurrentLineNumber());
}
}
diff --git a/src/test/java/org/apache/commons/csv/issues/JiraCsv211Test.java b/src/test/java/org/apache/commons/csv/issues/JiraCsv211Test.java
index 26dc702..d341c25 100644
--- a/src/test/java/org/apache/commons/csv/issues/JiraCsv211Test.java
+++ b/src/test/java/org/apache/commons/csv/issues/JiraCsv211Test.java
@@ -33,12 +33,12 @@ public class JiraCsv211Test {
final String[] values = new String[] { "1", "Jane Doe", "USA", "" };
final CSVFormat printFormat = CSVFormat.DEFAULT.withDelimiter('\t').withHeader("ID", "Name", "Country", "Age");
- String formatted = printFormat.format(values);
+ final String formatted = printFormat.format(values);
assertEquals("ID\tName\tCountry\tAge\r\n1\tJane Doe\tUSA\t", formatted);
final CSVFormat parseFormat = CSVFormat.DEFAULT.withDelimiter('\t').withFirstRecordAsHeader();
- CSVParser parser = parseFormat.parse(new StringReader(formatted));
- for (CSVRecord record : parser) {
+ final CSVParser parser = parseFormat.parse(new StringReader(formatted));
+ for (final CSVRecord record : parser) {
assertEquals("1", record.get(0));
assertEquals("Jane Doe", record.get(1));
assertEquals("USA", record.get(2));