com.google.common.collect.Maps.unmodifiableBiMap()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(164)

本文整理了Java中com.google.common.collect.Maps.unmodifiableBiMap()方法的一些代码示例,展示了Maps.unmodifiableBiMap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Maps.unmodifiableBiMap()方法的具体详情如下:
包路径:com.google.common.collect.Maps
类名称:Maps
方法名:unmodifiableBiMap

Maps.unmodifiableBiMap介绍

[英]Returns an unmodifiable view of the specified bimap. This method allows modules to provide users with "read-only" access to internal bimaps. Query operations on the returned bimap "read through" to the specified bimap, and attempts to modify the returned map, whether direct or via its collection views, result in an UnsupportedOperationException.

The returned bimap will be serializable if the specified bimap is serializable.
[中]返回指定bimap的不可修改视图。这种方法允许模块为用户提供对内部BIMAP的“只读”访问。对返回的bimap执行“读取”到指定bimap的查询操作,并尝试修改返回的映射,无论是直接修改还是通过其集合视图修改,都会导致不支持操作异常。
如果指定的bimap可序列化,则返回的bimap将可序列化。

代码示例

代码示例来源:origin: google/guava

@Override
 protected BiMap<String, String> create(Entry<String, String>[] entries) {
  BiMap<String, String> bimap = HashBiMap.create(entries.length);
  for (Entry<String, String> entry : entries) {
   checkArgument(!bimap.containsKey(entry.getKey()));
   bimap.put(entry.getKey(), entry.getValue());
  }
  return Maps.unmodifiableBiMap(bimap);
 }
})

代码示例来源:origin: google/error-prone

validKinds.put(Kind.EXTENDS_WILDCARD, BoundKind.EXTENDS);
validKinds.put(Kind.SUPER_WILDCARD, BoundKind.SUPER);
BOUND_KINDS = Maps.unmodifiableBiMap(validKinds);

代码示例来源:origin: google/guava

mod.put(3, "three");
BiMap<Number, String> unmod = Maps.<Number, String>unmodifiableBiMap(mod);

代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-generator-impl

public BiMap<Type, CaseSchemaNode> getCaseTypeToSchemas() {
  return Maps.unmodifiableBiMap(caseTypeToSchema);
}

代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding2-generator-api

public BiMap<Type, CaseSchemaNode> getCaseTypeToSchemas() {
  return Maps.unmodifiableBiMap(this.caseTypeToSchema);
}

代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-generator-impl

public BiMap<Type, AugmentationSchemaNode> getTypeToAugmentation() {
  return Maps.unmodifiableBiMap(typeToAugmentation);
}

代码示例来源:origin: org.opendaylight.yangtools/binding-generator-impl

public BiMap<Type, AugmentationSchema> getTypeToAugmentation() {
  return Maps.unmodifiableBiMap(typeToAugmentation);
}

代码示例来源:origin: org.opendaylight.yangtools/binding-generator-impl

public BiMap<Type, ChoiceCaseNode> getCaseTypeToSchemas() {
  return Maps.unmodifiableBiMap(caseTypeToSchema);
}

代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding2-generator-api

public BiMap<SchemaPath, Type> getTargetToAugmentation() {
  return Maps.unmodifiableBiMap(this.targetToAugmentation);
}

代码示例来源:origin: com.google.guava/guava-tests

@Override
 protected BiMap<String, String> create(Entry<String, String>[] entries) {
  BiMap<String, String> bimap = HashBiMap.create(entries.length);
  for (Entry<String, String> entry : entries) {
   checkArgument(!bimap.containsKey(entry.getKey()));
   bimap.put(entry.getKey(), entry.getValue());
  }
  return Maps.unmodifiableBiMap(bimap);
 }
})

代码示例来源:origin: com.google.errorprone/error_prone_core

validKinds.put(Kind.EXTENDS_WILDCARD, BoundKind.EXTENDS);
validKinds.put(Kind.SUPER_WILDCARD, BoundKind.SUPER);
BOUND_KINDS = Maps.unmodifiableBiMap(validKinds);

代码示例来源:origin: com.google.guava/guava-tests

mod.put(3, "three");
BiMap<Number, String> unmod = Maps.<Number, String>unmodifiableBiMap(mod);

相关文章