@@ -0,0 +1,2156 @@
+package stexfires.core.modifier;%0A%0Aimport stexfires.core.Record;%0Aimport stexfires.core.record.StandardRecord;%0A%0Aimport java.util.*;%0Aimport java.util.function.Function;%0Aimport java.util.function.IntFunction;%0Aimport java.util.stream.Stream;%0A%0A/**%0A * @author Mathias Kalb%0A * @since 0.1%0A */%0Apublic class UnpivotModifier%3CT extends Record, R extends Record%3E implements RecordStreamModifier%3CT, R%3E %7B%0A%0A    protected final Function%3C? super T, Stream%3C? extends R%3E%3E unpivotFunction;%0A%0A    public UnpivotModifier(Function%3C? super T, Stream%3C? extends R%3E%3E unpivotFunction) %7B%0A        Objects.requireNonNull(unpivotFunction);%0A        this.unpivotFunction = unpivotFunction;%0A    %7D%0A%0A    public static %3CT extends Record, R extends Record%3E UnpivotModifier%3CT, R%3E getInstance(Function%3C? super T, Collection%3C? extends R%3E%3E unpivotFunction) %7B%0A        Objects.requireNonNull(unpivotFunction);%0A        return new UnpivotModifier%3C%3E(record -%3E unpivotFunction.apply(record).stream());%0A    %7D%0A%0A    public static %3CT extends Record%3E UnpivotModifier%3CT, Record%3E getInstance(int keyIndex, IntFunction%3CString%3E nameFunction) %7B%0A        Objects.requireNonNull(nameFunction);%0A        return new UnpivotModifier%3C%3E(record -%3E %7B%0A            List%3CStandardRecord%3E list = new ArrayList%3C%3E(record.size() - 1);%0A            for (int i = 0; i %3C record.size(); i++) %7B%0A                if (i == keyIndex) %7B%0A                    continue;%0A                %7D%0A                list.add(new StandardRecord(record.getCategory(), record.getRecordId(), record.getValueAt(keyIndex), nameFunction.apply(i), record.getValueAt(i)));%0A            %7D%0A            return list.stream();%0A        %7D);%0A    %7D%0A%0A    public static %3CT extends Record%3E UnpivotModifier%3CT, Record%3E getInstance(int keyIndex) %7B%0A        return getInstance(keyIndex, String::valueOf);%0A    %7D%0A%0A    public static %3CT extends Record%3E UnpivotModifier%3CT, Record%3E getInstance(int keyIndex, Map%3CInteger, String%3E nameMap) %7B%0A        Objects.requireNonNull(nameMap);%0A        return getInstance(keyIndex, nameMap::get);%0A    %7D%0A%0A    @Override%0A    public Stream%3CR%3E modify(Stream%3CT%3E recordStream) %7B%0A        return recordStream.map(unpivotFunction).flatMap(Function.identity());%0A    %7D%0A%0A%7D%0A

Add UnpivotModifier