CollectionConverter.java 文件源码

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

项目:monarch 作者:
CollectionConverter(Type targetType, ArrayType openArrayType, Class openArrayClass,
    OpenTypeConverter elementConverter) {
  super(targetType, openArrayType, openArrayClass);
  this.elementConverter = elementConverter;

  /*
   * Determine the concrete class to be used when converting back to this Java type. We convert
   * all Lists to ArrayList and all Sets to TreeSet. (TreeSet because it is a SortedSet, so works
   * for both Set and SortedSet.)
   */
  Type raw = ((ParameterizedType) targetType).getRawType();
  Class c = (Class<?>) raw;
  if (c == List.class)
    collectionClass = ArrayList.class;
  else if (c == Set.class)
    collectionClass = HashSet.class;
  else if (c == SortedSet.class)
    collectionClass = TreeSet.class;
  else { // can't happen
    assert (false);
    collectionClass = null;
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号