Does dozer support list to list mapping?

Goods.java

@Getter
@Setter
public class Goods {
    private Integer id;

    private String url;

    private Integer groupId;

    private Integer sourceId;

    private Integer userId;

    private Date createTime;

    private Date updateTime;

}

GoodsVo.java

@Getter
@Setter
public class GoodsVo {

    private Integer id;

    private String url;

    private Integer groupId;

    private Integer sourceId;

    private Integer userId;
}
List<Goods> goods = goodsService.listGoodsByGroup(groupId);

I want to change List < Goods > to List < GoodsVo > . How can I change it? Thank you!


you have to do a simple package yourself to achieve


public class DozerUtils {

    /**
     * dozer:List<S> --> List<T>
     */
    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;
    }
}
Menu