FeatureUtil.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:guava-mock 作者:
/**
 * Find all the tester annotations declared on a tester class or method.
 * @param classOrMethod a class or method whose tester annotations to find
 * @return an iterable sequence of tester annotations on the class
 */
public static Iterable<Annotation> getTesterAnnotations(AnnotatedElement classOrMethod) {
  synchronized (annotationCache) {
    List<Annotation> annotations = annotationCache.get(classOrMethod);
    if (annotations == null) {
      annotations = new ArrayList<Annotation>();
      for (Annotation a : classOrMethod.getDeclaredAnnotations()) {
        if (a.annotationType().isAnnotationPresent(TesterAnnotation.class)) {
          annotations.add(a);
        }
      }
      annotations = Collections.unmodifiableList(annotations);
      annotationCache.put(classOrMethod, annotations);
    }
    return annotations;
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号