Skip to content

Commit 71a6570

Browse files
committed
Where possible:
- Add final modifier to private fields - Add final modifier to method parameters - Add final modifier to local variables git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1429926 13f79535-47bb-0310-9956-ffa450edef68
1 parent 98bc368 commit 71a6570

3 files changed

Lines changed: 29 additions & 29 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public int hashCode()
398398
}
399399

400400
@Override
401-
public boolean equals(Object obj)
401+
public boolean equals(final Object obj)
402402
{
403403
if (this == obj)
404404
{
@@ -413,7 +413,7 @@ public boolean equals(Object obj)
413413
return false;
414414
}
415415

416-
CSVFormat other = (CSVFormat) obj;
416+
final CSVFormat other = (CSVFormat) obj;
417417
if (delimiter != other.delimiter)
418418
{
419419
return false;
@@ -543,7 +543,7 @@ public static class CSVFormatBuilder {
543543
*/
544544
@SuppressWarnings("synthetic-access") // TODO fields could be made package-protected
545545
// package protected to give access without needing a synthetic accessor
546-
CSVFormatBuilder(CSVFormat format) {
546+
CSVFormatBuilder(final CSVFormat format) {
547547
this(format.delimiter, format.quoteChar, format.quotePolicy,
548548
format.commentStart, format.escape,
549549
format.ignoreSurroundingSpaces, format.ignoreEmptyLines,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,23 @@ public void testIgnoreEmptyLines() {
158158

159159
@Test
160160
public void testCopiedFormatIsEqualToOriginal() {
161-
CSVFormat copyOfRCF4180 = CSVFormat.newBuilder(RFC4180).build();
161+
final CSVFormat copyOfRCF4180 = CSVFormat.newBuilder(RFC4180).build();
162162
assertEquals(RFC4180, copyOfRCF4180);
163163
}
164164

165165
@Test
166166
public void testCopiedFormatWithChanges() {
167-
CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
167+
final CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
168168
assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
169169
}
170170

171171
@Test
172172
public void testHeaderReferenceCannotEscape() {
173-
String[] header = new String[]{"one", "tow", "three"};
173+
final String[] header = new String[]{"one", "tow", "three"};
174174
builder.withHeader(header);
175175

176-
CSVFormat firstFormat = builder.build();
177-
CSVFormat secondFormat = builder.build();
176+
final CSVFormat firstFormat = builder.build();
177+
final CSVFormat secondFormat = builder.build();
178178
assertNotSame(header, firstFormat.getHeader());
179179
assertNotSame(firstFormat, secondFormat.getHeader());
180180
}

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public void testSerialization() throws Exception {
6969

7070
@Test
7171
public void testEquals() {
72-
CSVFormat right = CSVFormat.DEFAULT;
73-
CSVFormat left = CSVFormat.newBuilder().build();
72+
final CSVFormat right = CSVFormat.DEFAULT;
73+
final CSVFormat left = CSVFormat.newBuilder().build();
7474

7575
assertFalse(right.equals(null));
7676
assertFalse(right.equals("A String Instance"));
@@ -85,27 +85,27 @@ public void testEquals() {
8585

8686
@Test
8787
public void testEqualsDelimiter() {
88-
CSVFormat right = CSVFormat.newBuilder('!').build();
89-
CSVFormat left = CSVFormat.newBuilder('?').build();
88+
final CSVFormat right = CSVFormat.newBuilder('!').build();
89+
final CSVFormat left = CSVFormat.newBuilder('?').build();
9090

9191
assertNotEquals(right, left);
9292
}
9393

9494
@Test
9595
public void testEqualsQuoteChar() {
96-
CSVFormat right = CSVFormat.newBuilder('\'').withQuoteChar('"').build();
97-
CSVFormat left = CSVFormat.newBuilder(right).withQuoteChar('!').build();
96+
final CSVFormat right = CSVFormat.newBuilder('\'').withQuoteChar('"').build();
97+
final CSVFormat left = CSVFormat.newBuilder(right).withQuoteChar('!').build();
9898

9999
assertNotEquals(right, left);
100100
}
101101

102102
@Test
103103
public void testEqualsQuotePolicy() {
104-
CSVFormat right = CSVFormat.newBuilder('\'')
104+
final CSVFormat right = CSVFormat.newBuilder('\'')
105105
.withQuoteChar('"')
106106
.withQuotePolicy(Quote.ALL)
107107
.build();
108-
CSVFormat left = CSVFormat.newBuilder(right)
108+
final CSVFormat left = CSVFormat.newBuilder(right)
109109
.withQuotePolicy(Quote.MINIMAL)
110110
.build();
111111

@@ -114,12 +114,12 @@ public void testEqualsQuotePolicy() {
114114

115115
@Test
116116
public void testEqualsCommentStart() {
117-
CSVFormat right = CSVFormat.newBuilder('\'')
117+
final CSVFormat right = CSVFormat.newBuilder('\'')
118118
.withQuoteChar('"')
119119
.withQuotePolicy(Quote.ALL)
120120
.withCommentStart('#')
121121
.build();
122-
CSVFormat left = CSVFormat.newBuilder(right)
122+
final CSVFormat left = CSVFormat.newBuilder(right)
123123
.withCommentStart('!')
124124
.build();
125125

@@ -128,13 +128,13 @@ public void testEqualsCommentStart() {
128128

129129
@Test
130130
public void testEqualsEscape() {
131-
CSVFormat right = CSVFormat.newBuilder('\'')
131+
final CSVFormat right = CSVFormat.newBuilder('\'')
132132
.withQuoteChar('"')
133133
.withQuotePolicy(Quote.ALL)
134134
.withCommentStart('#')
135135
.withEscape('+')
136136
.build();
137-
CSVFormat left = CSVFormat.newBuilder(right)
137+
final CSVFormat left = CSVFormat.newBuilder(right)
138138
.withEscape('!')
139139
.build();
140140

@@ -143,14 +143,14 @@ public void testEqualsEscape() {
143143

144144
@Test
145145
public void testEqualsIgnoreSurroundingSpaces() {
146-
CSVFormat right = CSVFormat.newBuilder('\'')
146+
final CSVFormat right = CSVFormat.newBuilder('\'')
147147
.withQuoteChar('"')
148148
.withQuotePolicy(Quote.ALL)
149149
.withCommentStart('#')
150150
.withEscape('+')
151151
.withIgnoreSurroundingSpaces(true)
152152
.build();
153-
CSVFormat left = CSVFormat.newBuilder(right)
153+
final CSVFormat left = CSVFormat.newBuilder(right)
154154
.withIgnoreSurroundingSpaces(false)
155155
.build();
156156

@@ -159,15 +159,15 @@ public void testEqualsIgnoreSurroundingSpaces() {
159159

160160
@Test
161161
public void testEqualsIgnoreEmptyLines() {
162-
CSVFormat right = CSVFormat.newBuilder('\'')
162+
final CSVFormat right = CSVFormat.newBuilder('\'')
163163
.withQuoteChar('"')
164164
.withQuotePolicy(Quote.ALL)
165165
.withCommentStart('#')
166166
.withEscape('+')
167167
.withIgnoreSurroundingSpaces(true)
168168
.withIgnoreEmptyLines(true)
169169
.build();
170-
CSVFormat left = CSVFormat.newBuilder(right)
170+
final CSVFormat left = CSVFormat.newBuilder(right)
171171
.withIgnoreEmptyLines(false)
172172
.build();
173173

@@ -176,7 +176,7 @@ public void testEqualsIgnoreEmptyLines() {
176176

177177
@Test
178178
public void testEqualsRecordSeparator() {
179-
CSVFormat right = CSVFormat.newBuilder('\'')
179+
final CSVFormat right = CSVFormat.newBuilder('\'')
180180
.withQuoteChar('"')
181181
.withQuotePolicy(Quote.ALL)
182182
.withCommentStart('#')
@@ -185,7 +185,7 @@ public void testEqualsRecordSeparator() {
185185
.withIgnoreEmptyLines(true)
186186
.withRecordSeparator('*')
187187
.build();
188-
CSVFormat left = CSVFormat.newBuilder(right)
188+
final CSVFormat left = CSVFormat.newBuilder(right)
189189
.withRecordSeparator('!')
190190
.build();
191191

@@ -194,7 +194,7 @@ public void testEqualsRecordSeparator() {
194194

195195
@Test
196196
public void testEqualsHeader() {
197-
CSVFormat right = CSVFormat.newBuilder('\'')
197+
final CSVFormat right = CSVFormat.newBuilder('\'')
198198
.withQuoteChar('"')
199199
.withQuotePolicy(Quote.ALL)
200200
.withCommentStart('#')
@@ -204,14 +204,14 @@ public void testEqualsHeader() {
204204
.withRecordSeparator('*')
205205
.withHeader("One", "Two", "Three")
206206
.build();
207-
CSVFormat left = CSVFormat.newBuilder(right)
207+
final CSVFormat left = CSVFormat.newBuilder(right)
208208
.withHeader("Three", "Two", "One")
209209
.build();
210210

211211
assertNotEquals(right, left);
212212
}
213213

214-
private static void assertNotEquals(Object right, Object left) {
214+
private static void assertNotEquals(final Object right, final Object left) {
215215
assertFalse(right.equals(left));
216216
assertFalse(left.equals(right));
217217
}

0 commit comments

Comments
 (0)