org.kuali.student.common.conversion.util.R1R2ConverterUtil Maven / Gradle / Ivy
package org.kuali.student.common.conversion.util;
import java.util.ArrayList;
import java.util.List;
import org.dozer.DozerBeanMapperSingletonWrapper;
import org.dozer.Mapper;
public class R1R2ConverterUtil {
private final static Mapper dozerMapper = DozerBeanMapperSingletonWrapper.getInstance();
public static X convert(T source, Class target) {
if (source == null){
return null;
}
return dozerMapper.map(source, target);
}
public static X convert(T source, X target) {
if (source == null){
return null;
}
dozerMapper.map(source, target);
return target;
}
public static List convertLists(List sourceList, Class targetListType) {
if (sourceList == null){
return null;
}
List targetList = new ArrayList();
for (T sourceObject : sourceList) {
X targetObject = convert(sourceObject, targetListType);
targetList.add(targetObject);
}
return targetList;
}
}