TypeKey.java 文件源码

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

项目:paperparcel 作者:
@Override public TypeKey visitTypeVariable(TypeVariable t, Set<TypeParameterElement> visited) {
  TypeParameterElement element = (TypeParameterElement) t.asElement();
  if (visited.contains(element)) {
    // This avoids infinite recursion with adapted types like <T extends Comparable<T>>.
    // It should probably check that T is bound correctly, but this is unlikely to be an issue
    // in the wild.
    return AnyKey.get(t.toString());
  }
  visited.add(element);
  ImmutableList.Builder<TypeKey> builder = ImmutableList.builder();
  for (TypeMirror bound : element.getBounds()) {
    TypeKey boundKey = bound.accept(this, visited);
    if (!boundKey.equals(OBJECT)) {
      builder.add(boundKey);
    }
  }
  ImmutableList<TypeKey> bounds = builder.build();
  if (bounds.size() == 0) {
    return AnyKey.get(t.toString());
  } else {
    return BoundedKey.get(t.toString(), bounds);
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号