Field f = Test.class.getDeclaredField("a");
boolean falg = f.getAnnotation(Bean.class);
@see获取含有注解属性 https://www.cnblogs.com/aademeng/articles/11218079.html
PropertyDescriptor类:(属性描述器)
PropertyDescriptor类表示JavaBean类通过存储器导出一个属性。主要方法:
1. getPropertyType(),获得属性的Class对象;
2. getReadMethod(),获得用于读取属性值的方法;
3. getWriteMethod(),获得用于写入属性值的方法;
4. hashCode(),获取对象的哈希值;
5. setReadMethod(Method readMethod),设置用于读取属性值的方法;
6. setWriteMethod(Method writeMethod),设置用于写入属性值的方法。
String fieldName = field.getName();
// 获取bean的某个属性的描述符
PropertyDescriptor pd = new PropertyDescriptor(fieldName, cla);
// 获得用于读取属性值的方法
Method readMethod = pd.getReadMethod();
// 读取属性值
Object val = readMethod.invoke(obj);
@see属性描述器 https://blog.csdn.net/weixin_42069143/article/details/82119724