All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.leeonky.dal.runtime.AutoMappingList Maven / Gradle / Ivy

package com.github.leeonky.dal.runtime;

import java.util.function.Function;

public class AutoMappingList extends DALCollection.Decorated {
    public AutoMappingList(Function mapper, DALCollection list) {
        super(list.map((index, data) -> {
            try {
                return mapper.apply(data);
            } catch (PropertyAccessException e) {
                throw new ListMappingElementAccessException(index, e);
            } catch (Exception e) {
                throw new ListMappingElementAccessException(index, new PropertyAccessException(e.getMessage(), e));
            }
        }));
    }
}