Skip to content

Commit 68352ee

Browse files
committed
Use the final keyword where possible.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1409464 13f79535-47bb-0310-9956-ffa450edef68
1 parent cdc8b8f commit 68352ee

7 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public class CSVFormat implements Serializable {
130130
* the char used for value separation, must not be a line break character
131131
* @throws IllegalArgumentException if the delimiter is a line break character
132132
*/
133-
public static CSVFormatBuilder newBuilder(char delimiter) {
133+
public static CSVFormatBuilder newBuilder(final char delimiter) {
134134
return new CSVFormatBuilder(delimiter);
135135
}
136136

@@ -430,7 +430,7 @@ public static class CSVFormatBuilder {
430430
* the char used for value separation, must not be a line break character
431431
* @throws IllegalArgumentException if the delimiter is a line break character
432432
*/
433-
private CSVFormatBuilder(char delimiter){
433+
private CSVFormatBuilder(final char delimiter){
434434
this(delimiter, null, null, null, null, false, false, null, null);
435435
}
436436

src/main/java/org/apache/commons/csv/CSVPrinter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void printComment(final String comment) throws IOException {
152152
println();
153153
}
154154

155-
private void print(Object object, final CharSequence value, final int offset, final int len) throws IOException {
155+
private void print(final Object object, final CharSequence value, final int offset, final int len) throws IOException {
156156
if (format.isQuoting()) {
157157
printAndQuote(object, value, offset, len);
158158
} else if (format.isEscaping()) {
@@ -215,7 +215,7 @@ void printAndEscape(final CharSequence value, final int offset, final int len) t
215215
/*
216216
* Note: must only be called if quoting is enabled, otherwise will generate NPE
217217
*/
218-
void printAndQuote(Object object, final CharSequence value, final int offset, final int len) throws IOException {
218+
void printAndQuote(final Object object, final CharSequence value, final int offset, final int len) throws IOException {
219219
final boolean first = newLine; // is this the first value on this line?
220220
boolean quote = false;
221221
int start = offset;
@@ -344,8 +344,8 @@ public void print(final Object value) throws IOException {
344344
* @throws IOException
345345
* If an I/O error occurs
346346
*/
347-
public void printRecords(Object[] values) throws IOException {
348-
for (Object value : values) {
347+
public void printRecords(final Object[] values) throws IOException {
348+
for (final Object value : values) {
349349
if (value instanceof Object[]) {
350350
this.printRecord((Object[]) value);
351351
} else if (value instanceof Iterable) {
@@ -364,8 +364,8 @@ public void printRecords(Object[] values) throws IOException {
364364
* @throws IOException
365365
* If an I/O error occurs
366366
*/
367-
public void printRecords(Iterable<?> values) throws IOException {
368-
for (Object value : values) {
367+
public void printRecords(final Iterable<?> values) throws IOException {
368+
for (final Object value : values) {
369369
if (value instanceof Object[]) {
370370
this.printRecord((Object[]) value);
371371
} else if (value instanceof Iterable) {
@@ -384,8 +384,8 @@ public void printRecords(Iterable<?> values) throws IOException {
384384
* @throws IOException
385385
* If an I/O error occurs
386386
*/
387-
public void printRecords(ResultSet resultSet) throws SQLException, IOException {
388-
int columnCount = resultSet.getMetaData().getColumnCount();
387+
public void printRecords(final ResultSet resultSet) throws SQLException, IOException {
388+
final int columnCount = resultSet.getMetaData().getColumnCount();
389389
while (resultSet.next()) {
390390
for (int i = 1; i <= columnCount; i++) {
391391
print(resultSet.getString(i));

src/main/java/org/apache/commons/csv/CSVRecord.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class CSVRecord implements Serializable, Iterable<String> {
4545
/** The record number. */
4646
private final long recordNumber;
4747

48-
CSVRecord(final String[] values, final Map<String, Integer> mapping, final String comment, long recordNumber) {
48+
CSVRecord(final String[] values, final Map<String, Integer> mapping, final String comment, final long recordNumber) {
4949
this.recordNumber = recordNumber;
5050
this.values = values != null ? values : EMPTY_STRING_ARRAY;
5151
this.mapping = mapping;

src/main/java/org/apache/commons/csv/Lexer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ abstract class Lexer {
6565
this.ignoreEmptyLines = format.getIgnoreEmptyLines();
6666
}
6767

68-
private final char mapNullToDisabled(Character c) {
68+
private final char mapNullToDisabled(final Character c) {
6969
return c == null ? DISABLED : c.charValue();
7070
}
7171

src/test/java/org/apache/commons/csv/CSVFileParserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void testCSVFile() throws Exception {
9090
assertTrue(testName+" require 1 param", split.length >= 1);
9191
// first line starts with csv data file name
9292
final BufferedReader csvFile = new BufferedReader(new FileReader(new File(BASE, split[0])));
93-
CSVFormatBuilder builder = CSVFormat.newBuilder(',').withQuoteChar('"');
93+
final CSVFormatBuilder builder = CSVFormat.newBuilder(',').withQuoteChar('"');
9494
CSVFormat fmt = builder.build();
9595
boolean checkComments = false;
9696
for(int i=1; i < split.length; i++) {

src/test/java/org/apache/commons/csv/CSVParserTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ public void testForEach() throws Exception {
440440

441441
@Test
442442
public void testRoundtrip() throws Exception {
443-
StringWriter out = new StringWriter();
444-
CSVPrinter printer = new CSVPrinter(out, CSVFormat.DEFAULT);
443+
final StringWriter out = new StringWriter();
444+
final CSVPrinter printer = new CSVPrinter(out, CSVFormat.DEFAULT);
445445
final String input = "a,b,c\r\n1,2,3\r\nx,y,z\r\n";
446446
for (final CSVRecord record : CSVFormat.DEFAULT.parse(new StringReader(input))) {
447447
printer.printRecord(record);
@@ -653,7 +653,7 @@ public void testGetRecordNumberWithCR() throws Exception {
653653
validateRecordNumbers(String.valueOf(CR));
654654
}
655655

656-
private void validateRecordNumbers(String lineSeparator) throws IOException {
656+
private void validateRecordNumbers(final String lineSeparator) throws IOException {
657657
final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.newBuilder().withRecordSeparator(lineSeparator).build());
658658
CSVRecord record;
659659
assertEquals(0, parser.getRecordNumber());
@@ -670,7 +670,7 @@ private void validateRecordNumbers(String lineSeparator) throws IOException {
670670
assertEquals(3, parser.getRecordNumber());
671671
}
672672

673-
private void validateLineNumbers(String lineSeparator) throws IOException {
673+
private void validateLineNumbers(final String lineSeparator) throws IOException {
674674
final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.newBuilder().withRecordSeparator(lineSeparator).build());
675675
assertEquals(0, parser.getLineNumber());
676676
assertNotNull(parser.nextRecord());

src/test/java/org/apache/commons/csv/perf/PerformanceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ private BufferedReader getBufferedReader() throws IOException {
6565
return new BufferedReader(new FileReader(BIG_FILE));
6666
}
6767

68-
private long parse(final Reader in, boolean traverseColumns) throws IOException {
68+
private long parse(final Reader in, final boolean traverseColumns) throws IOException {
6969
final CSVFormat format = CSVFormat.newBuilder().withIgnoreSurroundingSpaces(false).build();
7070
long recordCount = 0;
7171
for (final CSVRecord record : format.parse(in)) {
7272
recordCount++;
7373
if (traverseColumns) {
74-
for (String value : record) {
74+
for (final String value : record) {
7575
// do nothing for now
7676
}
7777
}
@@ -91,7 +91,7 @@ private long readAll(final BufferedReader in) throws IOException {
9191
return count;
9292
}
9393

94-
public long testParseBigFile(boolean traverseColumns) throws Exception {
94+
public long testParseBigFile(final boolean traverseColumns) throws Exception {
9595
final long startMillis = System.currentTimeMillis();
9696
final long count = this.parse(this.getBufferedReader(), traverseColumns);
9797
final long totalMillis = System.currentTimeMillis() - startMillis;

0 commit comments

Comments
 (0)