package org.textfiledatatools.core;

import org.textfiledatatools.core.producer.RecordProducer;
import org.textfiledatatools.core.producer.UncheckedProducerException;

import java.util.function.Function;
import java.util.stream.Stream;

/**
 * This class consists of {@code static} utility methods for operating on record streams.
 *
 * @author Mathias Kalb
 * @since 0.1
 */
public final class RecordStreams {

    private RecordStreams() {
    }

    public static Stream<Record> emptyStream() {
        return Stream.empty();
    }

    public static Stream<Record> newStream(Record record) {
        return Stream.of(record);
    }

    public static Stream<Record> newStream(Record... records) {
        return Stream.of(records);
    }

    public static <T extends Record> Stream<T> newStream(RecordProducer<T> recordProducer) throws UncheckedProducerException {
        return recordProducer.produceStream();
    }

    public static <T extends Record> Stream<T> concat(Stream<T> firstRecordStream, Stream<T> secondRecordStream) {
        return Stream.concat(firstRecordStream, secondRecordStream);
    }

    @SafeVarargs
    public static <T extends Record> Stream<T> concat(Stream<T>... recordStreams) {
        // TODO Validate: concatWithFlatMap or concatWithReduce
        return concatWithFlatMap(recordStreams);
    }

    @SafeVarargs
    static <T extends Record> Stream<T> concatWithFlatMap(Stream<T>... recordStreams) {
        return Stream.of(recordStreams).flatMap(Function.identity());
    }

    @SafeVarargs
    static <T extends Record> Stream<T> concatWithReduce(Stream<T>... recordStreams) {
        return Stream.of(recordStreams).reduce(Stream.empty(), Stream::concat);
    }

}

@@ -543,37 +543,51 @@
 blic static 
-Stream%3CRecord
+%3CT extends Record%3E Stream%3CT
 %3E newStream(
@@ -586,22 +586,17 @@
 wStream(
-Record
+T
  record)
@@ -657,29 +657,43 @@
  static 
-Stream%3CRecord
+%3CT extends Record%3E Stream%3CT
 %3E newStr
@@ -696,22 +696,17 @@
 wStream(
-Record
+T
 ... reco

Add static generics to "newStream" methods