RestAnalyzer.java 文件源码

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

项目:api-compiler 作者:
private static ImmutableMap<String, Map<CollectionAttribute, String>> generateShortNames(
    Collection<CollectionAttribute> collections) {
  // Map[version -> Map[name -> collection]] because collection name must be unique within a
  // given version, but likely is not unique across versions.
  Map<String, BiMap<String, CollectionAttribute>> versionMap = new HashMap<>();
  for (CollectionAttribute collection : collections) {
    String version = collection.getVersionWithDefault();
    if (!versionMap.containsKey(version)) {
      versionMap.put(version, HashBiMap.<String, CollectionAttribute>create());
    }
    String baseName = collection.getBaseName();
    String shortName = baseName.substring(baseName.lastIndexOf(".") + 1);
    insertOrDisambiguate(versionMap.get(version), shortName, collection);
  }

  ImmutableMap.Builder<String, Map<CollectionAttribute, String>> shortNames =
      new ImmutableMap.Builder<>();
  for (Map.Entry<String, BiMap<String, CollectionAttribute>> entry : versionMap.entrySet()) {
    shortNames.put(entry.getKey(), entry.getValue().inverse());
  }
  return shortNames.build();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号