package stexfires.core.mapper;

import stexfires.core.Fields;
import stexfires.core.Record;
import stexfires.core.mapper.fieldvalue.FieldValueMapper;
import stexfires.core.record.StandardRecord;

import java.util.Objects;

/**
 * @author Mathias Kalb
 * @since 0.1
 */
public class ValuesMapper implements UnaryRecordMapper<Record> {

    protected final FieldValueMapper fieldValueMapper;

    public ValuesMapper(FieldValueMapper fieldValueMapper) {
        Objects.requireNonNull(fieldValueMapper);
        this.fieldValueMapper = fieldValueMapper;
    }

    @Override
    public Record map(Record record) {
        if (record.isEmpty()) {
            return record;
        }
        return new StandardRecord(record.getCategory(), record.getRecordId(),
                Fields.collectValues(record, fieldValueMapper));
    }

}

@@ -25,16 +25,45 @@
 apper;%0A%0A
+import stexfires.core.Field;%0A
 import s
@@ -218,16 +218,39 @@
 ecord;%0A%0A
+import java.util.List;%0A
 import j
@@ -266,16 +266,88 @@
 Objects;
+%0Aimport java.util.function.Function;%0Aimport java.util.stream.Collectors;
 %0A%0A/**%0A *
@@ -477,41 +477,684 @@
 al F
-ield
+unction%3CRecord, List%3CString%3E%3E valuesFunction;%0A%0A    public ValuesMapper(Function%3CRecord, List%3CString%3E%3E valuesFunction) %7B%0A        Objects.requireNonNull(valuesFunction);%0A        this.valuesFunction = valuesFunction;%0A    %7D%0A%0A    public static 
 Value
+s
 Mapper 
-field
+getInstance(List%3CFunction%3CRecord, String%3E%3E functions) %7B%0A        Objects.requireNonNull(functions);%0A        return new ValuesMapper(r -%3E functions.stream().map(f -%3E f.apply(r)).collect(Collectors.toList()));%0A    %7D%0A%0A    public static ValuesMapper getInstance(Function%3CList%3CField%3E, List%3CString%3E%3E function) %7B%0A        Objects.requireNonNull(function);%0A        return new 
 Value
+s
 Mapper
-;
+(r -%3E function.apply(r.listOfFields()));%0A    %7D
 %0A%0A  
@@ -1154,32 +1154,39 @@
   %7D%0A%0A    public 
+static 
 ValuesMapper(Fie
@@ -1181,16 +1181,28 @@
 esMapper
+ getInstance
 (FieldVa
@@ -1293,31 +1293,60 @@
     
-this.field
+return new 
 Value
+s
 Mapper
- =
+(r -%3E Fields.collectValues(r,
  fie
@@ -1358,16 +1358,18 @@
 ueMapper
+))
 ;%0A    %7D%0A
@@ -1426,77 +1426,8 @@
 ) %7B%0A
-        if (record.isEmpty()) %7B%0A            return record;%0A        %7D%0A
     
@@ -1503,70 +1503,36 @@
 d(),
-%0A                Fields.collectValues(record, fieldValueMapper
+ valuesFunction.apply(record
 ));%0A

Enhance ValuesMapper