All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.iartisan.runtime.utils.BeanUtil Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package org.iartisan.runtime.utils;

import org.iartisan.runtime.bean.PageWrapper;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 

* * @author King * @since 2017/7/7 */ public class BeanUtil { public static T copyBean(Object resource, Class clazz) { try { T result = clazz.newInstance(); BeanUtils.copyProperties(resource, result); return result; } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return null; } public static List copyList(List resource, Class clazz) { List result = new ArrayList<>(); if (null != resource) { for (Object o : resource) { T t = copyBean(o, clazz); result.add(t); } } return result; } public static PageWrapper copyPage(PageWrapper dbPageWrapper, Class clazz) { PageWrapper resPage = new PageWrapper<>(dbPageWrapper.getPage()); if (null != dbPageWrapper) { List dataList = BeanUtil.copyList(dbPageWrapper.getData(), clazz); resPage.setData(dataList); } return resPage; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy