public static Map<String, String> getFieldAnnotation(Object object) {
Field[] fields = object.getClass().getDeclaredFields();
Map<String, String> resultMap = new HashMap();
for (Field field : fields) {
// 是否引用ApiModelProperty注解
boolean bool = field.isAnnotationPresent(ApiModelProperty.class);
if (bool) {
String value = field.getAnnotation(ApiModelProperty.class).value();
resultMap.put(field.getName(), value);
}
}
return resultMap;
}
java 判断对象的字段上是否有某个注解
最新推荐文章于 2024-06-15 14:50:57 发布