AnnotationCacheHelper.java 文件源码

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

项目:KraftRPG-API 作者:
/**
 * Builds the cache for the given class.
 *
 * @param target The target class
 */
public void build(Class<?> target) {
    if (this.cache.containsKey(target)) {
        return;
    }
    //System.out.println("Building cache for " + target.getName());
    Map<Class, List<Method>> anno = new MapMaker().weakKeys().makeMap();
    for (Method m : target.getMethods()) {
        for (Annotation a : m.getAnnotations()) {
            if (!anno.containsKey(a.annotationType())) {
                anno.put(a.annotationType(), Lists.<Method>newArrayList());
            }
            //System.out.println("\t" + a.annotationType().getSimpleName() + " - " + m.toGenericString());
            anno.get(a.annotationType()).add(m);
        }
    }
    this.cache.put(target, anno);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号