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
This commit is contained in:
parent
98bc368b31
commit
71a657004e
|
@ -398,7 +398,7 @@ public class CSVFormat implements Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
public boolean equals(final Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
|
@ -413,7 +413,7 @@ public class CSVFormat implements Serializable {
|
|||
return false;
|
||||
}
|
||||
|
||||
CSVFormat other = (CSVFormat) obj;
|
||||
final CSVFormat other = (CSVFormat) obj;
|
||||
if (delimiter != other.delimiter)
|
||||
{
|
||||
return false;
|
||||
|
@ -543,7 +543,7 @@ public class CSVFormat implements Serializable {
|
|||
*/
|
||||
@SuppressWarnings("synthetic-access") // TODO fields could be made package-protected
|
||||
// package protected to give access without needing a synthetic accessor
|
||||
CSVFormatBuilder(CSVFormat format) {
|
||||
CSVFormatBuilder(final CSVFormat format) {
|
||||
this(format.delimiter, format.quoteChar, format.quotePolicy,
|
||||
format.commentStart, format.escape,
|
||||
format.ignoreSurroundingSpaces, format.ignoreEmptyLines,
|
||||
|
|
|
@ -158,23 +158,23 @@ public class CSVFormatBuilderTest {
|
|||
|
||||
@Test
|
||||
public void testCopiedFormatIsEqualToOriginal() {
|
||||
CSVFormat copyOfRCF4180 = CSVFormat.newBuilder(RFC4180).build();
|
||||
final CSVFormat copyOfRCF4180 = CSVFormat.newBuilder(RFC4180).build();
|
||||
assertEquals(RFC4180, copyOfRCF4180);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopiedFormatWithChanges() {
|
||||
CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
|
||||
final CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
|
||||
assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderReferenceCannotEscape() {
|
||||
String[] header = new String[]{"one", "tow", "three"};
|
||||
final String[] header = new String[]{"one", "tow", "three"};
|
||||
builder.withHeader(header);
|
||||
|
||||
CSVFormat firstFormat = builder.build();
|
||||
CSVFormat secondFormat = builder.build();
|
||||
final CSVFormat firstFormat = builder.build();
|
||||
final CSVFormat secondFormat = builder.build();
|
||||
assertNotSame(header, firstFormat.getHeader());
|
||||
assertNotSame(firstFormat, secondFormat.getHeader());
|
||||
}
|
||||
|
|
|
@ -69,8 +69,8 @@ public class CSVFormatTest {
|
|||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
CSVFormat right = CSVFormat.DEFAULT;
|
||||
CSVFormat left = CSVFormat.newBuilder().build();
|
||||
final CSVFormat right = CSVFormat.DEFAULT;
|
||||
final CSVFormat left = CSVFormat.newBuilder().build();
|
||||
|
||||
assertFalse(right.equals(null));
|
||||
assertFalse(right.equals("A String Instance"));
|
||||
|
@ -85,27 +85,27 @@ public class CSVFormatTest {
|
|||
|
||||
@Test
|
||||
public void testEqualsDelimiter() {
|
||||
CSVFormat right = CSVFormat.newBuilder('!').build();
|
||||
CSVFormat left = CSVFormat.newBuilder('?').build();
|
||||
final CSVFormat right = CSVFormat.newBuilder('!').build();
|
||||
final CSVFormat left = CSVFormat.newBuilder('?').build();
|
||||
|
||||
assertNotEquals(right, left);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsQuoteChar() {
|
||||
CSVFormat right = CSVFormat.newBuilder('\'').withQuoteChar('"').build();
|
||||
CSVFormat left = CSVFormat.newBuilder(right).withQuoteChar('!').build();
|
||||
final CSVFormat right = CSVFormat.newBuilder('\'').withQuoteChar('"').build();
|
||||
final CSVFormat left = CSVFormat.newBuilder(right).withQuoteChar('!').build();
|
||||
|
||||
assertNotEquals(right, left);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsQuotePolicy() {
|
||||
CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
final CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
.withQuoteChar('"')
|
||||
.withQuotePolicy(Quote.ALL)
|
||||
.build();
|
||||
CSVFormat left = CSVFormat.newBuilder(right)
|
||||
final CSVFormat left = CSVFormat.newBuilder(right)
|
||||
.withQuotePolicy(Quote.MINIMAL)
|
||||
.build();
|
||||
|
||||
|
@ -114,12 +114,12 @@ public class CSVFormatTest {
|
|||
|
||||
@Test
|
||||
public void testEqualsCommentStart() {
|
||||
CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
final CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
.withQuoteChar('"')
|
||||
.withQuotePolicy(Quote.ALL)
|
||||
.withCommentStart('#')
|
||||
.build();
|
||||
CSVFormat left = CSVFormat.newBuilder(right)
|
||||
final CSVFormat left = CSVFormat.newBuilder(right)
|
||||
.withCommentStart('!')
|
||||
.build();
|
||||
|
||||
|
@ -128,13 +128,13 @@ public class CSVFormatTest {
|
|||
|
||||
@Test
|
||||
public void testEqualsEscape() {
|
||||
CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
final CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
.withQuoteChar('"')
|
||||
.withQuotePolicy(Quote.ALL)
|
||||
.withCommentStart('#')
|
||||
.withEscape('+')
|
||||
.build();
|
||||
CSVFormat left = CSVFormat.newBuilder(right)
|
||||
final CSVFormat left = CSVFormat.newBuilder(right)
|
||||
.withEscape('!')
|
||||
.build();
|
||||
|
||||
|
@ -143,14 +143,14 @@ public class CSVFormatTest {
|
|||
|
||||
@Test
|
||||
public void testEqualsIgnoreSurroundingSpaces() {
|
||||
CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
final CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
.withQuoteChar('"')
|
||||
.withQuotePolicy(Quote.ALL)
|
||||
.withCommentStart('#')
|
||||
.withEscape('+')
|
||||
.withIgnoreSurroundingSpaces(true)
|
||||
.build();
|
||||
CSVFormat left = CSVFormat.newBuilder(right)
|
||||
final CSVFormat left = CSVFormat.newBuilder(right)
|
||||
.withIgnoreSurroundingSpaces(false)
|
||||
.build();
|
||||
|
||||
|
@ -159,7 +159,7 @@ public class CSVFormatTest {
|
|||
|
||||
@Test
|
||||
public void testEqualsIgnoreEmptyLines() {
|
||||
CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
final CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
.withQuoteChar('"')
|
||||
.withQuotePolicy(Quote.ALL)
|
||||
.withCommentStart('#')
|
||||
|
@ -167,7 +167,7 @@ public class CSVFormatTest {
|
|||
.withIgnoreSurroundingSpaces(true)
|
||||
.withIgnoreEmptyLines(true)
|
||||
.build();
|
||||
CSVFormat left = CSVFormat.newBuilder(right)
|
||||
final CSVFormat left = CSVFormat.newBuilder(right)
|
||||
.withIgnoreEmptyLines(false)
|
||||
.build();
|
||||
|
||||
|
@ -176,7 +176,7 @@ public class CSVFormatTest {
|
|||
|
||||
@Test
|
||||
public void testEqualsRecordSeparator() {
|
||||
CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
final CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
.withQuoteChar('"')
|
||||
.withQuotePolicy(Quote.ALL)
|
||||
.withCommentStart('#')
|
||||
|
@ -185,7 +185,7 @@ public class CSVFormatTest {
|
|||
.withIgnoreEmptyLines(true)
|
||||
.withRecordSeparator('*')
|
||||
.build();
|
||||
CSVFormat left = CSVFormat.newBuilder(right)
|
||||
final CSVFormat left = CSVFormat.newBuilder(right)
|
||||
.withRecordSeparator('!')
|
||||
.build();
|
||||
|
||||
|
@ -194,7 +194,7 @@ public class CSVFormatTest {
|
|||
|
||||
@Test
|
||||
public void testEqualsHeader() {
|
||||
CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
final CSVFormat right = CSVFormat.newBuilder('\'')
|
||||
.withQuoteChar('"')
|
||||
.withQuotePolicy(Quote.ALL)
|
||||
.withCommentStart('#')
|
||||
|
@ -204,14 +204,14 @@ public class CSVFormatTest {
|
|||
.withRecordSeparator('*')
|
||||
.withHeader("One", "Two", "Three")
|
||||
.build();
|
||||
CSVFormat left = CSVFormat.newBuilder(right)
|
||||
final CSVFormat left = CSVFormat.newBuilder(right)
|
||||
.withHeader("Three", "Two", "One")
|
||||
.build();
|
||||
|
||||
assertNotEquals(right, left);
|
||||
}
|
||||
|
||||
private static void assertNotEquals(Object right, Object left) {
|
||||
private static void assertNotEquals(final Object right, final Object left) {
|
||||
assertFalse(right.equals(left));
|
||||
assertFalse(left.equals(right));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue