Use Stream.of() and rename new method to be like Collection#stream()
instead of toStream().
This commit is contained in:
parent
805d329bda
commit
a0fcf9a5a5
|
@ -24,8 +24,8 @@ 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;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* A CSV record parsed from a CSV file.
|
||||
|
@ -289,6 +289,16 @@ public final class CSVRecord implements Serializable, Iterable<String> {
|
|||
return values.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequential ordered stream whose elements are the values.
|
||||
*
|
||||
* @return the new stream.
|
||||
* @since 1.9.0
|
||||
*/
|
||||
public Stream<String> stream() {
|
||||
return Stream.of(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the values to a List.
|
||||
*
|
||||
|
@ -308,16 +318,6 @@ 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[])}.
|
||||
|
|
|
@ -54,10 +54,7 @@ public class CSVFileParserTest {
|
|||
public static Stream<File> generateData() {
|
||||
final FilenameFilter fileNameFilter = (dir, name) -> name.startsWith("test") && name.endsWith(".txt");
|
||||
final File[] files = BASE.listFiles(fileNameFilter);
|
||||
if (files != null) {
|
||||
return Arrays.stream(files);
|
||||
}
|
||||
return Stream.empty();
|
||||
return files != null ? Stream.of(files) : Stream.empty();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
|
|
@ -298,9 +298,9 @@ public class CSVRecordTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testToStream() {
|
||||
public void testStream() {
|
||||
final AtomicInteger i = new AtomicInteger();
|
||||
record.toStream().forEach(value -> {
|
||||
record.stream().forEach(value -> {
|
||||
assertEquals(values[i.get()], value);
|
||||
i.incrementAndGet();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue