Java?е???????
???????????? ???????[ 2016/4/5 11:20:07 ] ??????????????????? Java
????Java??÷?????????get set ????
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
*
*/
/**
* @ClassName: ReflectTest
* @Description: TODO(????????仰??????????????)
* @author zhoushun
* @date 2013??11??26?? ????5:11:35
*
*/
public class ReflectTest {
public static void main() throws Exception{
ReflectTest bo = new ReflectTest();
Field[] fields = bo.getClass().getDeclaredFields();
// д????
for(Field ff : fields) {
String name = ff.getName(); //????????????
String type = ff.getGenericType().toString(); //????????????
ff.setAccessible(true);
PropertyDescriptor pd = new PropertyDescriptor(ff.getName()?? bo.getClass());
Method rM = pd.getReadMethod();//????????
Object num = (Object) rM.invoke(bo);
if(num == null) {
Method wM = pd.getWriteMethod();//???д????
if(type.equals("class java.lang.Integer")){
}
if(type.equals("class java.lang.Short")){
}
if(type.equals("class java.lang.Double")){
}
if(type.equals("class java.lang.Boolean")){
}
if(type.equals("class java.util.Date")){
}
wM.invoke(bo?? "1");//????????int?????????????????int??????????????????????ж???????????????
}
}
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11