mirror of
https://github.com/apache/commons-csv.git
synced 2025-02-08 02:59:26 +00:00
Remove redundant keywords
This commit is contained in:
parent
ab37149709
commit
e835cb2de9
@ -151,7 +151,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (CSVParser.this.isClosed()) {
|
||||
if (isClosed()) {
|
||||
return false;
|
||||
}
|
||||
if (current == null) {
|
||||
@ -163,7 +163,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
|
||||
|
||||
@Override
|
||||
public CSVRecord next() {
|
||||
if (CSVParser.this.isClosed()) {
|
||||
if (isClosed()) {
|
||||
throw new NoSuchElementException("CSVParser has been closed");
|
||||
}
|
||||
CSVRecord next = current;
|
||||
|
@ -110,7 +110,7 @@ public final class CSVPrinter implements Flushable, Closeable {
|
||||
final String[] headerComments = format.getHeaderComments();
|
||||
if (headerComments != null) {
|
||||
for (final String line : headerComments) {
|
||||
this.printComment(line);
|
||||
printComment(line);
|
||||
}
|
||||
}
|
||||
if (format.getHeader() != null && !format.getSkipHeaderRecord()) {
|
||||
|
@ -54,13 +54,11 @@ import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.io.input.BOMInputStream;
|
||||
import org.apache.commons.io.input.BrokenInputStream;
|
||||
import org.apache.commons.lang3.stream.Streams.FailableStream;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
/**
|
||||
* CSVParserTest
|
||||
@ -754,17 +752,17 @@ public class CSVParserTest {
|
||||
|
||||
@Test
|
||||
public void testGetLineNumberWithCR() throws Exception {
|
||||
this.validateLineNumbers(String.valueOf(CR));
|
||||
validateLineNumbers(String.valueOf(CR));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLineNumberWithCRLF() throws Exception {
|
||||
this.validateLineNumbers(CRLF);
|
||||
validateLineNumbers(CRLF);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLineNumberWithLF() throws Exception {
|
||||
this.validateLineNumbers(String.valueOf(LF));
|
||||
validateLineNumbers(String.valueOf(LF));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -797,27 +795,27 @@ public class CSVParserTest {
|
||||
|
||||
@Test
|
||||
public void testGetRecordNumberWithCR() throws Exception {
|
||||
this.validateRecordNumbers(String.valueOf(CR));
|
||||
validateRecordNumbers(String.valueOf(CR));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecordNumberWithCRLF() throws Exception {
|
||||
this.validateRecordNumbers(CRLF);
|
||||
validateRecordNumbers(CRLF);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecordNumberWithLF() throws Exception {
|
||||
this.validateRecordNumbers(String.valueOf(LF));
|
||||
validateRecordNumbers(String.valueOf(LF));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecordPositionWithCRLF() throws Exception {
|
||||
this.validateRecordPosition(CRLF);
|
||||
validateRecordPosition(CRLF);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecordPositionWithLF() throws Exception {
|
||||
this.validateRecordPosition(String.valueOf(LF));
|
||||
validateRecordPosition(String.valueOf(LF));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1329,7 +1327,7 @@ public class CSVParserTest {
|
||||
assertEquals("xyz", csvRecord.get(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseWithDelimiterStringWithQuote() throws IOException {
|
||||
final String source = "'a[|]b[|]c'[|]xyz\r\nabc[abc][|]xyz";
|
||||
@ -1343,7 +1341,7 @@ public class CSVParserTest {
|
||||
assertEquals("xyz", csvRecord.get(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseWithDelimiterWithEscape() throws IOException {
|
||||
final String source = "a!,b!,c,xyz";
|
||||
@ -1354,7 +1352,7 @@ public class CSVParserTest {
|
||||
assertEquals("xyz", csvRecord.get(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseWithDelimiterWithQuote() throws IOException {
|
||||
final String source = "'a,b,c',xyz";
|
||||
@ -1365,7 +1363,7 @@ public class CSVParserTest {
|
||||
assertEquals("xyz", csvRecord.get(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseWithQuoteThrowsException() {
|
||||
final CSVFormat csvFormat = CSVFormat.DEFAULT.withQuote('\'');
|
||||
@ -1373,7 +1371,7 @@ public class CSVParserTest {
|
||||
assertThrows(IOException.class, () -> csvFormat.parse(new StringReader("'a,b,c'abc,xyz")).nextRecord());
|
||||
assertThrows(IOException.class, () -> csvFormat.parse(new StringReader("'abc'a,b,c',xyz")).nextRecord());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseWithQuoteWithEscape() throws IOException {
|
||||
final String source = "'a?,b?,c?d',xyz";
|
||||
@ -1384,7 +1382,7 @@ public class CSVParserTest {
|
||||
assertEquals("xyz", csvRecord.get(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(CSVFormat.Predefined.class)
|
||||
public void testParsingPrintedEmptyFirstColumn(final CSVFormat.Predefined format) throws Exception {
|
||||
|
@ -236,10 +236,10 @@ public class CSVRecordTest {
|
||||
public void testPutInMap() {
|
||||
final Map<String, String> map = new ConcurrentHashMap<>();
|
||||
this.recordWithHeader.putIn(map);
|
||||
this.validateMap(map, false);
|
||||
validateMap(map, false);
|
||||
// Test that we can compile with assignment to the same map as the param.
|
||||
final TreeMap<String, String> map2 = recordWithHeader.putIn(new TreeMap<>());
|
||||
this.validateMap(map2, false);
|
||||
validateMap(map2, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -339,7 +339,7 @@ public class CSVRecordTest {
|
||||
@Test
|
||||
public void testToMap() {
|
||||
final Map<String, String> map = this.recordWithHeader.toMap();
|
||||
this.validateMap(map, true);
|
||||
validateMap(map, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -100,10 +100,10 @@ public class PerformanceTest {
|
||||
|
||||
public long testParseBigFile(final boolean traverseColumns) throws Exception {
|
||||
final long startMillis = System.currentTimeMillis();
|
||||
try (final BufferedReader reader = this.createBufferedReader()) {
|
||||
final long count = this.parse(reader, traverseColumns);
|
||||
try (final BufferedReader reader = createBufferedReader()) {
|
||||
final long count = parse(reader, traverseColumns);
|
||||
final long totalMillis = System.currentTimeMillis() - startMillis;
|
||||
this.println(
|
||||
println(
|
||||
String.format("File parsed in %,d milliseconds with Commons CSV: %,d lines.", totalMillis, count));
|
||||
return totalMillis;
|
||||
}
|
||||
@ -113,9 +113,9 @@ public class PerformanceTest {
|
||||
public void testParseBigFileRepeat() throws Exception {
|
||||
long bestTime = Long.MAX_VALUE;
|
||||
for (int i = 0; i < this.max; i++) {
|
||||
bestTime = Math.min(this.testParseBigFile(false), bestTime);
|
||||
bestTime = Math.min(testParseBigFile(false), bestTime);
|
||||
}
|
||||
this.println(String.format("Best time out of %,d is %,d milliseconds.", this.max, bestTime));
|
||||
println(String.format("Best time out of %,d is %,d milliseconds.", this.max, bestTime));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -124,14 +124,14 @@ public class PerformanceTest {
|
||||
long count;
|
||||
for (int i = 0; i < this.max; i++) {
|
||||
final long startMillis;
|
||||
try (final BufferedReader in = this.createBufferedReader()) {
|
||||
try (final BufferedReader in = createBufferedReader()) {
|
||||
startMillis = System.currentTimeMillis();
|
||||
count = this.readAll(in);
|
||||
count = readAll(in);
|
||||
}
|
||||
final long totalMillis = System.currentTimeMillis() - startMillis;
|
||||
bestTime = Math.min(totalMillis, bestTime);
|
||||
this.println(String.format("File read in %,d milliseconds: %,d lines.", totalMillis, count));
|
||||
println(String.format("File read in %,d milliseconds: %,d lines.", totalMillis, count));
|
||||
}
|
||||
this.println(String.format("Best time out of %,d is %,d milliseconds.", this.max, bestTime));
|
||||
println(String.format("Best time out of %,d is %,d milliseconds.", this.max, bestTime));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user