Use final.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1559908 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d01e6b5421
commit
59411494e0
|
@ -28,7 +28,7 @@ final class Assertions {
|
|||
// can not be instantiated
|
||||
}
|
||||
|
||||
public static void notNull(Object parameter, String parameterName) {
|
||||
public static void notNull(final Object parameter, final String parameterName) {
|
||||
if (parameter == null) {
|
||||
throw new IllegalArgumentException("Parameter '" + parameterName + "' must not be null!");
|
||||
}
|
||||
|
|
|
@ -293,7 +293,7 @@ public final class CSVFormat implements Serializable {
|
|||
final Quote quotePolicy, final Character commentStart,
|
||||
final Character escape, final boolean ignoreSurroundingSpaces,
|
||||
final boolean ignoreEmptyLines, final String recordSeparator,
|
||||
final String nullString, final String[] header, boolean skipHeaderRecord) {
|
||||
final String nullString, final String[] header, final boolean skipHeaderRecord) {
|
||||
if (isLineBreak(delimiter)) {
|
||||
throw new IllegalArgumentException("The delimiter cannot be a line break");
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
|
|||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public static CSVParser parse(File file, final CSVFormat format) throws IOException {
|
||||
public static CSVParser parse(final File file, final CSVFormat format) throws IOException {
|
||||
Assertions.notNull(file, "file");
|
||||
Assertions.notNull(format, "format");
|
||||
|
||||
|
@ -165,7 +165,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
|
|||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public static CSVParser parse(String string, final CSVFormat format) throws IOException {
|
||||
public static CSVParser parse(final String string, final CSVFormat format) throws IOException {
|
||||
Assertions.notNull(string, "string");
|
||||
Assertions.notNull(format, "format");
|
||||
|
||||
|
@ -192,7 +192,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
|
|||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public static CSVParser parse(URL url, Charset charset, final CSVFormat format) throws IOException {
|
||||
public static CSVParser parse(final URL url, final Charset charset, final CSVFormat format) throws IOException {
|
||||
Assertions.notNull(url, "url");
|
||||
Assertions.notNull(charset, "charset");
|
||||
Assertions.notNull(format, "format");
|
||||
|
|
|
@ -62,7 +62,7 @@ public final class CSVRecord implements Serializable, Iterable<String> {
|
|||
* an enum
|
||||
* @return the String at the given enum String
|
||||
*/
|
||||
public String get(Enum<?> e) {
|
||||
public String get(final Enum<?> e) {
|
||||
return get(e.toString());
|
||||
}
|
||||
|
||||
|
@ -175,8 +175,8 @@ public final class CSVRecord implements Serializable, Iterable<String> {
|
|||
* @param map The Map to populate.
|
||||
* @return the given map.
|
||||
*/
|
||||
public Map<String, String> putIn(Map<String, String> map) {
|
||||
for (Entry<String, Integer> entry : mapping.entrySet()) {
|
||||
public Map<String, String> putIn(final Map<String, String> map) {
|
||||
for (final Entry<String, Integer> entry : mapping.entrySet()) {
|
||||
map.put(entry.getKey(), values[entry.getValue().intValue()]);
|
||||
}
|
||||
return map;
|
||||
|
|
|
@ -154,7 +154,7 @@ public class CSVFileParserTest {
|
|||
assertEquals(testName + " Expected format ", line, format.toString());
|
||||
|
||||
// Now parse the file and compare against the expected results
|
||||
URL resource = ClassLoader.getSystemResource("CSVFileParser/" + split[0]);
|
||||
final URL resource = ClassLoader.getSystemResource("CSVFileParser/" + split[0]);
|
||||
final CSVParser parser = CSVParser.parse(resource, Charset.forName("UTF-8"), format);
|
||||
for (final CSVRecord record : parser) {
|
||||
String parsed = record.toString();
|
||||
|
|
|
@ -493,17 +493,17 @@ public class CSVParserTest {
|
|||
|
||||
@Test // TODO this may lead to strange behavior, throw an exception if iterator() has already been called?
|
||||
public void testMultipleIterators() throws Exception {
|
||||
CSVParser parser = CSVParser.parse("a,b,c" + CR + "d,e,f", CSVFormat.DEFAULT);
|
||||
final CSVParser parser = CSVParser.parse("a,b,c" + CR + "d,e,f", CSVFormat.DEFAULT);
|
||||
|
||||
Iterator<CSVRecord> itr1 = parser.iterator();
|
||||
Iterator<CSVRecord> itr2 = parser.iterator();
|
||||
final Iterator<CSVRecord> itr1 = parser.iterator();
|
||||
final Iterator<CSVRecord> itr2 = parser.iterator();
|
||||
|
||||
CSVRecord first = itr1.next();
|
||||
final CSVRecord first = itr1.next();
|
||||
assertEquals("a", first.get(0));
|
||||
assertEquals("b", first.get(1));
|
||||
assertEquals("c", first.get(2));
|
||||
|
||||
CSVRecord second = itr2.next();
|
||||
final CSVRecord second = itr2.next();
|
||||
assertEquals("d", second.get(0));
|
||||
assertEquals("e", second.get(1));
|
||||
assertEquals("f", second.get(2));
|
||||
|
|
|
@ -118,7 +118,7 @@ public class CSVRecordTest {
|
|||
@Test
|
||||
public void testIterator() {
|
||||
int i = 0;
|
||||
for (String value : record) {
|
||||
for (final String value : record) {
|
||||
assertEquals(values[i], value);
|
||||
i++;
|
||||
}
|
||||
|
@ -126,18 +126,18 @@ public class CSVRecordTest {
|
|||
|
||||
@Test
|
||||
public void testPutInMap() {
|
||||
Map<String, String> map = new ConcurrentHashMap<String, String>();
|
||||
final Map<String, String> map = new ConcurrentHashMap<String, String>();
|
||||
this.recordWithHeader.putIn(map);
|
||||
this.validateMap(map, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToMap() {
|
||||
Map<String, String> map = this.recordWithHeader.toMap();
|
||||
final Map<String, String> map = this.recordWithHeader.toMap();
|
||||
this.validateMap(map, true);
|
||||
}
|
||||
|
||||
private void validateMap(Map<String, String> map, boolean allowsNulls) {
|
||||
private void validateMap(final Map<String, String> map, final boolean allowsNulls) {
|
||||
assertTrue(map.containsKey("first"));
|
||||
assertTrue(map.containsKey("second"));
|
||||
assertTrue(map.containsKey("third"));
|
||||
|
|
|
@ -43,7 +43,7 @@ public class FercGovTest {
|
|||
|
||||
@Test
|
||||
public void testContractFile() throws IOException {
|
||||
URL contractData = ClassLoader.getSystemClassLoader().getResource("ferc.gov/contract.txt");
|
||||
final URL contractData = ClassLoader.getSystemClassLoader().getResource("ferc.gov/contract.txt");
|
||||
final CSVParser parser = CSVParser.parse(contractData, US_ASCII,
|
||||
CSVFormat.DEFAULT.withHeader());
|
||||
try {
|
||||
|
@ -67,7 +67,7 @@ public class FercGovTest {
|
|||
|
||||
@Test
|
||||
public void testTransactionFile() throws IOException {
|
||||
URL transactionData = ClassLoader.getSystemClassLoader().getResource("ferc.gov/transaction.txt");
|
||||
final URL transactionData = ClassLoader.getSystemClassLoader().getResource("ferc.gov/transaction.txt");
|
||||
final CSVParser parser = CSVParser.parse(transactionData, US_ASCII,
|
||||
CSVFormat.DEFAULT.withHeader());
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue