[CSV-275] Make CSVRecord.toList() public.

This commit is contained in:
Gary Gregory 2021-06-23 14:54:49 -04:00
parent 00fcb06bb5
commit f9f9feb80e
3 changed files with 14 additions and 3 deletions

View File

@ -39,6 +39,7 @@
</properties>
<body>
<release version="1.9" date="2020-MM-DD" description="Feature and bug fix release (Java 8)">
<!-- FIX -->
<action type="add" dev="ggregory" due-to="dota17">Add test cases for CSVRecord with get(Enum) and toString. #54.</action>
<action type="update" dev="ggregory" due-to="Amey Jadiye">Replace FindBugs with SpotBugs #56.</action>
<action type="update" dev="ggregory" due-to="Chen">Javadoc typo in CSVFormat let's -> lets #57.</action>
@ -57,6 +58,7 @@
<action issue="CSV-267" type="fix" dev="ggregory" due-to="Arturo Bernal">Minor improvements #126, #127.</action>
<action issue="CSV-123" type="fix" dev="ggregory" due-to="Emmanuel Bourg, Benedikt Ritter, shivakrishnaah, Gary Gregory">Add possibility to use ResultSet header meta data as CSV header #11.</action>
<!-- ADD -->
<action issue="CSV-275" type="add" dev="ggregory" due-to="Michael Wyraz, Gary Gregory">Make CSVRecord#toList() public.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Update org.junit.jupiter:junit-jupiter from 5.6.0 to 5.7.0, #84 #109</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Update tests from Apache Commons Lang 3.9 to 3.12.0.</action>

View File

@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Stream;
import java.util.Objects;
/**
@ -291,11 +292,10 @@ public final class CSVRecord implements Serializable, Iterable<String> {
/**
* Converts the values to a List.
*
* TODO: Maybe make this public?
*
* @return a new List
* @since 1.9.0
*/
private List<String> toList() {
public List<String> toList() {
return Arrays.asList(values);
}

View File

@ -248,6 +248,15 @@ public class CSVRecordTest {
}
}
@Test
public void testToList() {
int i = 0;
for (final String value : record.toList()) {
assertEquals(values[i], value);
i++;
}
}
@Test
public void testToMap() {
final Map<String, String> map = this.recordWithHeader.toMap();