[英]How can I get the Declared Fields of a Java Class on an Annotation Processor?
Hi I am currently trying my hand at an AnnotationProcessor for Java.嗨,我目前正在尝试 Java 的 AnnotationProcessor。 The only problem I have now is how to get the Declared Fields for the class over which the annotation is placed.我现在唯一的问题是如何获取放置注释的 class 的声明字段。
Does anyone know how to get the fields?有谁知道如何获得这些领域?
Once you get the element, you loop over the enclosed elements and filter by element kind:获取元素后,循环封闭的元素并按元素类型过滤:
typeElement.getEnclosedElements().stream()
.filter(e -> ElementKind.FIELD.equals(e.getKind()))
.collect(Collectors.toList());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.