Skip to content

Commit ee6f52c

Browse files
committed
Use final. Use shorthand syntax for array creation.
1 parent 489aaf2 commit ee6f52c

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ public void testEqualsHash() throws Exception {
261261
final Object b = method.invoke(CSVFormat.DEFAULT, QuoteMode.ALL);
262262
assertNotEquals(name, type, a, b);
263263
} else if ("org.apache.commons.csv.DuplicateHeaderMode".equals(type)) {
264-
final Object a = method.invoke(CSVFormat.DEFAULT, new Object[] {DuplicateHeaderMode.ALLOW_ALL});
265-
final Object b = method.invoke(CSVFormat.DEFAULT, new Object[] {DuplicateHeaderMode.DISALLOW});
264+
final Object a = method.invoke(CSVFormat.DEFAULT, DuplicateHeaderMode.ALLOW_ALL);
265+
final Object b = method.invoke(CSVFormat.DEFAULT, DuplicateHeaderMode.DISALLOW);
266266
assertNotEquals(name, type, a, b);
267267
} else if ("java.lang.Object[]".equals(type)){
268268
final Object a = method.invoke(CSVFormat.DEFAULT, new Object[] {new Object[] {null, null}});

src/test/java/org/apache/commons/csv/issues/JiraCsv288Test.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public class JiraCsv288Test {
3434
// expected: <a,b,c,d,,f> but was: <a,b|c,d,|f>
3535
public void testParseWithDoublePipeDelimiter() throws Exception {
3636
final Reader in = new StringReader("a||b||c||d||||f");
37-
StringBuilder stringBuilder = new StringBuilder();
37+
final StringBuilder stringBuilder = new StringBuilder();
3838
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
3939
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("||").build())) {
40-
for (CSVRecord csvRecord : csvParser) {
40+
for (final CSVRecord csvRecord : csvParser) {
4141
for (int i = 0; i < csvRecord.size(); i++) {
4242
csvPrinter.print(csvRecord.get(i));
4343
}
@@ -51,10 +51,10 @@ public void testParseWithDoublePipeDelimiter() throws Exception {
5151
// expected: <a,b,c,d,,f> but was: <a,b|c,d,|f>
5252
public void testParseWithTriplePipeDelimiter() throws Exception {
5353
final Reader in = new StringReader("a|||b|||c|||d||||||f");
54-
StringBuilder stringBuilder = new StringBuilder();
54+
final StringBuilder stringBuilder = new StringBuilder();
5555
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
5656
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("|||").build())) {
57-
for (CSVRecord csvRecord : csvParser) {
57+
for (final CSVRecord csvRecord : csvParser) {
5858
for (int i = 0; i < csvRecord.size(); i++) {
5959
csvPrinter.print(csvRecord.get(i));
6060
}
@@ -68,10 +68,10 @@ public void testParseWithTriplePipeDelimiter() throws Exception {
6868
// expected: <a,b,c,d,,f> but was: <a,b,c,d,|f>
6969
public void testParseWithABADelimiter() throws Exception {
7070
final Reader in = new StringReader("a|~|b|~|c|~|d|~||~|f");
71-
StringBuilder stringBuilder = new StringBuilder();
71+
final StringBuilder stringBuilder = new StringBuilder();
7272
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
7373
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("|~|").build())) {
74-
for (CSVRecord csvRecord : csvParser) {
74+
for (final CSVRecord csvRecord : csvParser) {
7575
for (int i = 0; i < csvRecord.size(); i++) {
7676
csvPrinter.print(csvRecord.get(i));
7777
}
@@ -85,10 +85,10 @@ public void testParseWithABADelimiter() throws Exception {
8585
// expected: <a,b||c,d,,f> but was: <a,b||c,d,|f>
8686
public void testParseWithDoublePipeDelimiterQuoted() throws Exception {
8787
final Reader in = new StringReader("a||\"b||c\"||d||||f");
88-
StringBuilder stringBuilder = new StringBuilder();
88+
final StringBuilder stringBuilder = new StringBuilder();
8989
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
9090
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("||").build())) {
91-
for (CSVRecord csvRecord : csvParser) {
91+
for (final CSVRecord csvRecord : csvParser) {
9292
for (int i = 0; i < csvRecord.size(); i++) {
9393
csvPrinter.print(csvRecord.get(i));
9494
}
@@ -102,10 +102,10 @@ public void testParseWithDoublePipeDelimiterQuoted() throws Exception {
102102
// expected: <a,b,c,d,,f,> but was: <a,b|c,d,|f>
103103
public void testParseWithDoublePipeDelimiterEndsWithDelimiter() throws Exception {
104104
final Reader in = new StringReader("a||b||c||d||||f||");
105-
StringBuilder stringBuilder = new StringBuilder();
105+
final StringBuilder stringBuilder = new StringBuilder();
106106
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
107107
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("||").build())) {
108-
for (CSVRecord csvRecord : csvParser) {
108+
for (final CSVRecord csvRecord : csvParser) {
109109
for (int i = 0; i < csvRecord.size(); i++) {
110110
csvPrinter.print(csvRecord.get(i));
111111
}
@@ -119,10 +119,10 @@ public void testParseWithDoublePipeDelimiterEndsWithDelimiter() throws Exception
119119
// expected: <a,b,c,d,,f,> but was: <a,b,c,d,,f>
120120
public void testParseWithTwoCharDelimiterEndsWithDelimiter() throws Exception {
121121
final Reader in = new StringReader("a~|b~|c~|d~|~|f~|");
122-
StringBuilder stringBuilder = new StringBuilder();
122+
final StringBuilder stringBuilder = new StringBuilder();
123123
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
124124
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("~|").build())) {
125-
for (CSVRecord csvRecord : csvParser) {
125+
for (final CSVRecord csvRecord : csvParser) {
126126
for (int i = 0; i < csvRecord.size(); i++) {
127127
csvPrinter.print(csvRecord.get(i));
128128
}
@@ -136,10 +136,10 @@ public void testParseWithTwoCharDelimiterEndsWithDelimiter() throws Exception {
136136

137137
public void testParseWithDoublePipeDelimiterDoubleCharValue() throws Exception {
138138
final Reader in = new StringReader("a||bb||cc||dd||f");
139-
StringBuilder stringBuilder = new StringBuilder();
139+
final StringBuilder stringBuilder = new StringBuilder();
140140
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
141141
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("||").build())) {
142-
for (CSVRecord csvRecord : csvParser) {
142+
for (final CSVRecord csvRecord : csvParser) {
143143
for (int i = 0; i < csvRecord.size(); i++) {
144144
csvPrinter.print(csvRecord.get(i));
145145
}
@@ -152,10 +152,10 @@ public void testParseWithDoublePipeDelimiterDoubleCharValue() throws Exception {
152152
// Regression, already passed before fix
153153
public void testParseWithTwoCharDelimiter1() throws Exception {
154154
final Reader in = new StringReader("a~|b~|c~|d~|~|f");
155-
StringBuilder stringBuilder = new StringBuilder();
155+
final StringBuilder stringBuilder = new StringBuilder();
156156
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
157157
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("~|").build())) {
158-
for (CSVRecord csvRecord : csvParser) {
158+
for (final CSVRecord csvRecord : csvParser) {
159159
for (int i = 0; i < csvRecord.size(); i++) {
160160
csvPrinter.print(csvRecord.get(i));
161161
}
@@ -168,10 +168,10 @@ public void testParseWithTwoCharDelimiter1() throws Exception {
168168
// Regression, already passed before fix
169169
public void testParseWithTwoCharDelimiter2() throws Exception {
170170
final Reader in = new StringReader("a~|b~|c~|d~|~|f~");
171-
StringBuilder stringBuilder = new StringBuilder();
171+
final StringBuilder stringBuilder = new StringBuilder();
172172
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
173173
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("~|").build())) {
174-
for (CSVRecord csvRecord : csvParser) {
174+
for (final CSVRecord csvRecord : csvParser) {
175175
for (int i = 0; i < csvRecord.size(); i++) {
176176
csvPrinter.print(csvRecord.get(i));
177177
}
@@ -184,10 +184,10 @@ public void testParseWithTwoCharDelimiter2() throws Exception {
184184
// Regression, already passed before fix
185185
public void testParseWithTwoCharDelimiter3() throws Exception {
186186
final Reader in = new StringReader("a~|b~|c~|d~|~|f|");
187-
StringBuilder stringBuilder = new StringBuilder();
187+
final StringBuilder stringBuilder = new StringBuilder();
188188
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
189189
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("~|").build())) {
190-
for (CSVRecord csvRecord : csvParser) {
190+
for (final CSVRecord csvRecord : csvParser) {
191191
for (int i = 0; i < csvRecord.size(); i++) {
192192
csvPrinter.print(csvRecord.get(i));
193193
}
@@ -200,10 +200,10 @@ public void testParseWithTwoCharDelimiter3() throws Exception {
200200
// Regression, already passed before fix
201201
public void testParseWithTwoCharDelimiter4() throws Exception {
202202
final Reader in = new StringReader("a~|b~|c~|d~|~|f~~||g");
203-
StringBuilder stringBuilder = new StringBuilder();
203+
final StringBuilder stringBuilder = new StringBuilder();
204204
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
205205
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("~|").build())) {
206-
for (CSVRecord csvRecord : csvParser) {
206+
for (final CSVRecord csvRecord : csvParser) {
207207
for (int i = 0; i < csvRecord.size(); i++) {
208208
csvPrinter.print(csvRecord.get(i));
209209
}
@@ -216,10 +216,10 @@ public void testParseWithTwoCharDelimiter4() throws Exception {
216216
// Regression, already passed before fix
217217
public void testParseWithSinglePipeDelimiterEndsWithDelimiter() throws Exception {
218218
final Reader in = new StringReader("a|b|c|d||f|");
219-
StringBuilder stringBuilder = new StringBuilder();
219+
final StringBuilder stringBuilder = new StringBuilder();
220220
try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
221221
CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("|").build())) {
222-
for (CSVRecord csvRecord : csvParser) {
222+
for (final CSVRecord csvRecord : csvParser) {
223223
for (int i = 0; i < csvRecord.size(); i++) {
224224
csvPrinter.print(csvRecord.get(i));
225225
}

0 commit comments

Comments
 (0)