ecology_maven/weaver/aiyh_pcn/async_organization/util/GetModelValue.java

21 lines
542 B
Java

package weaver.aiyh_pcn.async_organization.util;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* @author EBU7-dev1-ayh
* @create 2021/7/26 0026 8:55
* 获取model类的属性值
*/
public class GetModelValue<T> {
public Object getValueForString(T obj, String mothodName) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Class<?> clazz = obj.getClass();
Method getValue = clazz.getDeclaredMethod("get" + mothodName);
return getValue.invoke(obj);
}
}