Add CSVRecord#toStream().
This commit is contained in:
parent
2d6090b6dd
commit
56d9c8d48f
|
@ -59,6 +59,7 @@
|
|||
<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>
|
||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add CSVRecord#toStream().</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>
|
||||
|
|
|
@ -308,6 +308,16 @@ public final class CSVRecord implements Serializable, Iterable<String> {
|
|||
return putIn(new LinkedHashMap<String, String>(values.length));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequential ordered stream whose elements are the values.
|
||||
*
|
||||
* @return the new stream.
|
||||
* @since 1.9.0
|
||||
*/
|
||||
public Stream<String> toStream() {
|
||||
return Arrays.stream(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of this record. The result is constructed by comment, mapping,
|
||||
* recordNumber and by passing the internal values array to {@link Arrays#toString(Object[])}.
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -296,6 +297,15 @@ public class CSVRecordTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToStream() {
|
||||
final AtomicInteger i = new AtomicInteger();
|
||||
record.toStream().forEach(value -> {
|
||||
assertEquals(values[i.get()], value);
|
||||
i.incrementAndGet();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
assertNotNull(recordWithHeader.toString());
|
||||
|
|
Loading…
Reference in New Issue