com.lone.common.util.ListUtilsForMy Maven / Gradle / Ivy
The newest version!
package com.lone.common.util;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.beanutils.BeanUtils;
public class ListUtilsForMy {
/**
* 按新的Class对象复制
*
* @param source list, example: list
* @param dest class, example: UserEntity.class;
*/
public static List copyTo(List source, Class destinationClass)
throws Exception {
if (source.size() == 0)
return new ArrayList();
List res = new ArrayList(source.size());
for (Object o : source) {
E e = destinationClass.newInstance();
BeanUtils.copyProperties(e, o);
res.add(e);
}
return res;
}
public static boolean isNullOrEmpty(List list)
{
return list == null || list.isEmpty();
}
}