说明:
1、getFields():获得某个类的所有的公共(public)的字段,包括父类中的字段。
2、getDeclaredFields():获得某个类的所有声明的字段,即包括public、private和proteced,但是不包括父类的申明字段。
3、同样类似的还有getConstructors()和getDeclaredConstructors()、getMethods()和getDeclaredMethods(),这两者分别表示获取某个类的方法、构造函数。
一、自定义编写方法获取父类所有字段:
要获取到当前类以及父类的所有属性,怎么办?
/*
* Copyright (C) 2013 SHANGHAI VOLKSWAGEN, All rights reserved.
* License version 1.0, a copy of which has been included with this.
* @File name:com.hkl.modules.utils.AnnotationUtil
* @Create on:2021/9/29
* @Author:hkl
*/
package com.hkl.modules.utils;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* <p>ClassName:AnnotationUtil</p >