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

top.netkit.toolkit.base.Convertible Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy