top.netkit.toolkit.base.Convertible Maven / Gradle / Ivy
package top.netkit.toolkit.base;
import top.netkit.toolkit.util.BeanCopierUtil;
/**
* convertible
* @author shixinke
*/
public interface Convertible {
/**
* object convert
* @param clazz target class
* @param class object
* @return T
*/
default T convert(Class clazz) {
T targetObject = null;
try {
targetObject = clazz.newInstance();
BeanCopierUtil.copy(this, targetObject, null);
} catch (Exception e) {
e.printStackTrace();
}
return targetObject;
}
}