@@ -0,0 +1,1788 @@
+package stexfires.core.mapper;%0A%0Aimport stexfires.core.Record;%0Aimport stexfires.core.message.RecordMessage;%0A%0Aimport java.util.Map;%0Aimport java.util.Objects;%0Aimport java.util.function.Function;%0A%0A/**%0A * @author Mathias Kalb%0A * @since 0.1%0A */%0Apublic class LookupMapper%3CT extends Record, R extends Record, K%3E implements RecordMapper%3CT, R%3E %7B%0A%0A    protected final Function%3C? super T, K%3E keyFunction;%0A    protected final Function%3CK, RecordMapper%3C? super T, ? extends R%3E%3E mapperFunction;%0A    protected final RecordMapper%3C? super T, ? extends R%3E defaultMapper;%0A%0A    public LookupMapper(Function%3C? super T, K%3E keyFunction,%0A                        Function%3CK, RecordMapper%3C? super T, ? extends R%3E%3E mapperFunction,%0A                        RecordMapper%3C? super T, ? extends R%3E defaultMapper) %7B%0A        Objects.requireNonNull(keyFunction);%0A        Objects.requireNonNull(mapperFunction);%0A        Objects.requireNonNull(defaultMapper);%0A        this.keyFunction = keyFunction;%0A        this.mapperFunction = mapperFunction;%0A        this.defaultMapper = defaultMapper;%0A    %7D%0A%0A    public static %3CT extends Record%3E LookupMapper%3CT, Record, String%3E messageMap(RecordMessage%3C? super T%3E recordMessage,%0A                                                                                Map%3CString, RecordMapper%3C? super T, Record%3E%3E recordMapperMap) %7B%0A        Objects.requireNonNull(recordMessage);%0A        Objects.requireNonNull(recordMapperMap);%0A        return new LookupMapper%3C%3E(recordMessage.asFunction(), recordMapperMap::get, new IdentityMapper%3C%3E());%0A    %7D%0A%0A    @Override%0A    public R map(T record) %7B%0A        RecordMapper%3C? super T, ? extends R%3E recordMapper = mapperFunction.apply(keyFunction.apply(record));%0A        return (recordMapper == null) ? defaultMapper.map(record) : recordMapper.map(record);%0A    %7D%0A%0A%7D%0A

Add LookupMapper