001 package org.kuali.student.common.conversion.util;
002
003 import java.util.ArrayList;
004 import java.util.List;
005
006 import org.dozer.DozerBeanMapperSingletonWrapper;
007 import org.dozer.Mapper;
008
009 public class R1R2ConverterUtil {
010
011 private final static Mapper dozerMapper = DozerBeanMapperSingletonWrapper.getInstance();
012
013 public static <T, X> X convert(T source, Class<X> target) {
014 if (source == null){
015 return null;
016 }
017
018 return dozerMapper.map(source, target);
019 }
020
021 public static <T, X> X convert(T source, X target) {
022 if (source == null){
023 return null;
024 }
025
026 dozerMapper.map(source, target);
027 return target;
028 }
029
030 public static <T, X> List<X> convertLists(List<T> sourceList, Class<X> targetListType) {
031 if (sourceList == null){
032 return null;
033 }
034
035 List<X> targetList = new ArrayList<X>();
036 for (T sourceObject : sourceList) {
037 X targetObject = convert(sourceObject, targetListType);
038 targetList.add(targetObject);
039 }
040 return targetList;
041 }
042
043 }