
com.codingapi.springboot.framework.convert.BeanConvertor Maven / Gradle / Ivy
package com.codingapi.springboot.framework.convert;
import org.springframework.beans.BeanUtils;
import java.lang.reflect.InvocationTargetException;
public class BeanConvertor {
public static T convert(S source, Class clazz) {
if (source == null) {
return null;
}
T target = null;
try {
target = clazz.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException |
InvocationTargetException e) {
return null;
}
BeanUtils.copyProperties(source, target);
return target;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy