其他分享
首页 > 其他分享> > Dozer DO与VO转换(List)

Dozer DO与VO转换(List)

作者:互联网

Dozer只支持Class转换,不支持List-to-List。以下代码块用于List转换。

import java.util.ArrayList;
import java.util.List;

import org.dozer.Mapper;

public class DozerUtils {

    /**
     * Encapsulate the method of dozer processing set: List < s > > > < T > List
     */
    public static <T, S> List<T> mapList(final Mapper mapper, List<S> sourceList, Class<T> targetObjectClass) {
        List<T> targetList = new ArrayList<T>();
        for (S s : sourceList) {
            targetList.add(mapper.map(s, targetObjectClass));
        }
        return targetList;
    }
}

标签:DO,Dozer,List,Class,sourceList,dozer,import,targetList
来源: https://www.cnblogs.com/2yue/p/dozer_list.html