package org.textfiledatatools.core.producer;

import org.textfiledatatools.core.Records;
import org.textfiledatatools.core.record.KeyValueRecord;
import org.textfiledatatools.util.Strings;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Mathias Kalb
 * @since 0.1
 */
public class KeyValueProducer implements RecordProducer<KeyValueRecord> {

    protected final List<KeyValueRecord> records;

    public KeyValueProducer(Map<?, ?> keyValueMap) {
        this(null, Records.recordIdSequence(), keyValueMap);
    }

    public KeyValueProducer(String category, Map<?, ?> keyValueMap) {
        this(category, Records.recordIdSequence(), keyValueMap);
    }

    public KeyValueProducer(String category, Supplier<Long> recordIdSupplier, Map<?, ?> keyValueMap) {
        Objects.requireNonNull(recordIdSupplier);
        Objects.requireNonNull(keyValueMap);
        records = keyValueMap.entrySet()
                .stream()
                .map(entry -> new KeyValueRecord(category, recordIdSupplier.get(), entry.getKey().toString(), Strings.asString(entry.getValue())))
                .collect(Collectors.toList());
    }

    @Override
    public Stream<KeyValueRecord> produceStream() {
        return records.stream();
    }

}

@@ -254,16 +254,52 @@
 bjects;%0A
+import java.util.function.Function;%0A
 import j
@@ -925,32 +925,259 @@
  keyValueMap) %7B%0A
+        this(category, recordIdSupplier, keyValueMap, Strings::asString);%0A    %7D%0A%0A    public KeyValueProducer(String category, Supplier%3CLong%3E recordIdSupplier, Map%3C?, ?%3E keyValueMap, Function%3CObject, String%3E toStringFunction) %7B%0A
         Objects.
@@ -1405,16 +1405,39 @@
 .get(), 
+toStringFunction.apply(
 entry.ge
@@ -1446,17 +1446,19 @@
 ey()
-.
+), 
 toString
 (), 
@@ -1457,28 +1457,22 @@
 ring
-(), Strings.asString
+Function.apply
 (ent

Add constructor with Function