Author: ggregory
Date: Wed Jan 22 16:07:23 2014
New Revision: 1560399
URL: http://svn.apache.org/r1560399
Log:
Fix generics issue.
Modified:
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java
Modified:
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
URL:
http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java?rev=1560399&r1=1560398&r2=1560399&view=diff
==============================================================================
---
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
(original)
+++
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
Wed Jan 22 16:07:23 2014
@@ -176,7 +176,7 @@ public final class CSVRecord implements
* @param map The Map to populate.
* @return the given map.
*/
- Map<String, String> putIn(final Map<String, String> map) {
+ <M extends Map<String, String>> M putIn(final M map) {
for (final Entry<String, Integer> entry : mapping.entrySet()) {
map.put(entry.getKey(), values[entry.getValue().intValue()]);
}
Modified:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java?rev=1560399&r1=1560398&r2=1560399&view=diff
==============================================================================
---
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java
(original)
+++
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVRecordTest.java
Wed Jan 22 16:07:23 2014
@@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import org.junit.Assert;
@@ -133,6 +134,9 @@ public class CSVRecordTest {
final Map<String, String> map = new ConcurrentHashMap<String,
String>();
this.recordWithHeader.putIn(map);
this.validateMap(map, false);
+ // Test that we can compile with assigment to the same map as the
param.
+ final TreeMap<String, String> map2 = recordWithHeader.putIn(new
TreeMap<String, String>());
+ this.validateMap(map2, false);
}
@Test
@@ -141,7 +145,7 @@ public class CSVRecordTest {
final CSVPrinter printer = new CSVPrinter(new StringBuilder(),
CSVFormat.DEFAULT);
final Map<String, String> map = recordWithHeader.toMap();
map.remove("OldColumn");
- map.put("NewColumn", "NewValue");
+ map.put("ZColumn", "NewValue");
// check:
final ArrayList<String> list = new ArrayList<String>(map.values());
Collections.sort(list);