将注释存储在地图中,稍后再查找

问题描述 投票:0回答:1

有没有办法在地图中存储对象的注释?

class HasFieldsWithAnnotations {

    Set<Annotation> annots = new HashSet<>();

    public boolean hasAnnotation(Annotation a) {
      return this.annots.contains(a);
    }
}

然后我们实例化它:

var c = new HasFieldsWithAnnotations();
c.hasAnnotation(?);

如何将注释传递给hasAnnotation方法?

java annotations
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.