com.sc.utils.mapper.BeanMapper Maven / Gradle / Ivy
The newest version!
package com.sc.utils.mapper;
import com.google.common.collect.Lists;
import org.dozer.DozerBeanMapper;
import java.util.Collection;
import java.util.List;
public class BeanMapper {
private static DozerBeanMapper dozer = new DozerBeanMapper();
public static T map(Object source, Class destinationClass) {
return dozer.map(source, destinationClass);
}
public static List mapList(Collection sourceList, Class destinationClass) {
List destinationList = Lists.newArrayList();
for (Object sourceObject : sourceList) {
T destinationObject = dozer.map(sourceObject, destinationClass);
destinationList.add(destinationObject);
}
return destinationList;
}
public static void copy(Object source, Object destinationObject) {
dozer.map(source, destinationObject);
}
}