package com.microservices.wiki.refactoring.utils;


import com.microservices.wiki.refactoring.exception.BusiException;
import org.springframework.beans.BeanUtils;

public class BeanCopyUtils {
    public static <T> T beanPropertiesCopy(Object source, Class clazz) {
        T target = null;
        try {
            target =  (T) clazz.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new BusiException(e.toString());
        }
        BeanUtils.copyProperties(source, target);
        return target;
    }
}

