本文整理匯總了Java中com.google.common.collect.ImmutableBiMap類的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableBiMap類的具體用法?Java ImmutableBiMap怎麽用?Java ImmutableBiMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ImmutableBiMap類屬於com.google.common.collect包,在下文中一共展示了ImmutableBiMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildModObjectList
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.<ModContainer, Object>builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
示例2: use
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
default void use() {
ImmutableExtraCollection.of(
ImmutableList.<String>of(),
ImmutableMultimap.<Integer, String>of(),
ImmutableMultimap.<Integer, String>of(),
ImmutableMultimap.<Integer, String>of(),
ImmutableBiMap.<Integer, String>of());
ImmutableExtraCollection.of();
ImmutableExtraCollection collection = ImmutableExtraCollection.builder()
.addBag("2", "2")
.putIndex(1, "2", "3", "4")
.putAllIndex(1, Arrays.asList("2", "3", "4"))
.putIndex(2, "5")
.putIndexList(1, "")
.putIndexSet(2, "2")
.putAllIndexSet(2, Arrays.asList("3", "4"))
.putBiMap(1, "a")
.putBiMap(2, "b")
.putAllBiMap(Collections.singletonMap(3, "c"))
.build();
collection.bag().count("2");
collection.index().get(1);
collection.indexList().get(1);
collection.indexSet().get(2);
}
示例3: from
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
public static ClassRenamingMapper from(ClassNameMapper originalMap, ClassNameMapper targetMap) {
ImmutableBiMap.Builder<String, String> translationBuilder = ImmutableBiMap.builder();
ImmutableSet.Builder<String> newClasses = ImmutableSet.builder();
BiMap<String, String> sourceObfuscatedToOriginal = originalMap.getObfuscatedToOriginalMapping();
BiMap<String, String> sourceOriginalToObfuscated = sourceObfuscatedToOriginal.inverse();
BiMap<String, String> targetObfuscatedToOriginal = targetMap.getObfuscatedToOriginalMapping();
BiMap<String, String> targetOriginalToObfuscated = targetObfuscatedToOriginal.inverse();
for (String originalName : sourceOriginalToObfuscated.keySet()) {
String sourceObfuscatedName = sourceOriginalToObfuscated.get(originalName);
String targetObfuscatedName = targetOriginalToObfuscated.get(originalName);
if (targetObfuscatedName == null) {
newClasses.add(originalName);
continue;
}
translationBuilder.put(sourceObfuscatedName, targetObfuscatedName);
}
ImmutableBiMap<String, String> translation = translationBuilder.build();
ImmutableSet<String> unusedNames = ImmutableSet
.copyOf(Sets.difference(targetObfuscatedToOriginal.keySet(), translation.values()));
return new ClassRenamingMapper(translation, newClasses.build(), unusedNames);
}
示例4: matchJustificationsForDoc
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
private static ImmutableSet<CharOffsetSpan> matchJustificationsForDoc(
final Iterable<DocEventFrameReference> eventFramesMatchedInDoc,
final DocumentSystemOutput2015 docSystemOutput) {
final Optional<ImmutableBiMap<String, ResponseSet>> responseSetMap =
docSystemOutput.linking().responseSetIds();
checkState(responseSetMap.isPresent());
final ImmutableSet.Builder<CharOffsetSpan> offsetsB = ImmutableSet.builder();
for (final DocEventFrameReference docEventFrameReference : eventFramesMatchedInDoc) {
final ResponseSet rs =
checkNotNull(responseSetMap.get().get(docEventFrameReference.eventFrameID()));
final ImmutableSet<Response> responses = rs.asSet();
final ImmutableSet<CharOffsetSpan> spans = FluentIterable.from(responses)
.transformAndConcat(ResponseFunctions.predicateJustifications()).toSet();
offsetsB.addAll(spans);
}
return offsetsB.build();
}
示例5: build
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
GqlInputConverter build() {
HashBiMap<String, Descriptor> mapping = HashBiMap.create();
HashBiMap<String, EnumDescriptor> enumMapping = HashBiMap.create(getEnumMap(enumDescriptors));
LinkedList<Descriptor> loop = new LinkedList<>(descriptors);
Set<FileDescriptor> fileDescriptorSet = ProtoRegistry.extractDependencies(fileDescriptors);
for (FileDescriptor fileDescriptor : fileDescriptorSet) {
loop.addAll(fileDescriptor.getMessageTypes());
enumMapping.putAll(getEnumMap(fileDescriptor.getEnumTypes()));
}
while (!loop.isEmpty()) {
Descriptor descriptor = loop.pop();
if (!mapping.containsKey(descriptor.getFullName())) {
mapping.put(getReferenceName(descriptor), descriptor);
loop.addAll(descriptor.getNestedTypes());
enumMapping.putAll(getEnumMap(descriptor.getEnumTypes()));
}
}
return new GqlInputConverter(
ImmutableBiMap.copyOf(mapping), ImmutableBiMap.copyOf(enumMapping));
}
示例6: testUpdateBiMapDate
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
/**
* HashBiMap 修改數據
* putAll
* remove
* replace
*/
@Test
public void testUpdateBiMapDate() {
BiMap<String, String> biMap = HashBiMap.create();
biMap.put("k1", "v1");
biMap.put("k2", "v2");
// putAll , 存入另一個Map的數據,此時如果value有重複的依然會拋異常
biMap.putAll(ImmutableBiMap.of("k3", "v3", "k4", "v4", "k5", "v5", "k6", "v6"));
System.out.println("biMap putAll after: " + biMap);
System.out.println("\n-------------------------------------------\n");
// remove , 移除指定key的元素,如果key不存在,則返回null
String v2 = biMap.remove("k2");
String valueNotExists = biMap.remove("keyNotExists");
System.out.println("remove k2 then biMap= " + biMap + ", and remove the value= " + v2);
System.out.println("valueNotExists=" + valueNotExists);
System.out.println("\n-------------------------------------------\n");
// 清空map裏的數據
biMap.clear();
System.out.println("clean biMap=" + biMap);
}
示例7: buildModObjectList
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
示例8: resolveShardForPath
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
Long resolveShardForPath(final YangInstanceIdentifier path) {
final String shardName = actorContext.getShardStrategyFactory().getStrategy(path).findShard(path);
Long cookie = shards.get(shardName);
if (cookie == null) {
synchronized (this) {
cookie = shards.get(shardName);
if (cookie == null) {
cookie = nextShard++;
Builder<String, Long> builder = ImmutableBiMap.builder();
builder.putAll(shards);
builder.put(shardName, cookie);
shards = builder.build();
}
}
}
return cookie;
}
示例9: ModuleRegistry
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
/**
* Creates a new {@link ModuleRegistry}
*
* @param modules The modules in the registry to be created.
*/
public ModuleRegistry(@NonNull Map<Class, Module> modules) {
Validate.notNull(modules);
this.modules = new ImmutableBiMap.Builder<Class, Module>().putAll(modules).build();
DependencyGraph<Module> graph = new DependencyGraph<Module>();
this.modules.values().forEach(module -> {
graph.add(module);
ModuleEntry moduleEntry = module.getClass().getAnnotation(ModuleEntry.class);
for (Class dep : moduleEntry.depends()) {
graph.addDependency(module, modules.get(dep));
}
for (Class before : moduleEntry.loadBefore()) {
graph.addDependency(modules.get(before), module);
}
});
loadOrder = graph.evaluateDependencies();
}
示例10: LanternBlockState
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
LanternBlockState(LanternBlockStateMap baseState, ImmutableMap<BlockTrait<?>, Comparable<?>> traitValues) {
this.traitValues = traitValues;
this.baseState = baseState;
ImmutableBiMap.Builder<Key<Value<?>>, BlockTrait<?>> builder = ImmutableBiMap.builder();
for (BlockTrait trait : traitValues.keySet()) {
builder.put(((LanternBlockTrait) trait).getKey(), trait);
}
this.keyToBlockTrait = builder.build();
final StringBuilder idBuilder = new StringBuilder();
idBuilder.append(baseState.getBlockType().getId().substring(baseState.getBlockType().getPluginId().length() + 1));
if (!traitValues.isEmpty()) {
idBuilder.append('[');
final Joiner joiner = Joiner.on(',');
final List<String> propertyValues = new ArrayList<>();
for (Map.Entry<BlockTrait<?>, Comparable<?>> entry : traitValues.entrySet()) {
propertyValues.add(entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase(Locale.ENGLISH));
}
idBuilder.append(joiner.join(propertyValues));
idBuilder.append(']');
}
this.name = idBuilder.toString();
this.id = baseState.getBlockType().getPluginId() + ':' + this.name;
}
示例11: Support
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
Support(final Expr expr, final String body, final Set<URI> properties,
final Map<String, String> namespaces) {
super(null, XPathFunction.CONTEXT, VARIABLES, XPathNavigator.INSTANCE);
final StringBuilder builder = new StringBuilder();
for (final String prefix : Ordering.natural().sortedCopy(namespaces.keySet())) {
final String namespace = namespaces.get(prefix);
if (!namespace.equals(Data.getNamespaceMap().get(prefix))) {
builder.append(builder.length() == 0 ? "" : ", ").append(prefix).append(": ")
.append("<").append(namespace).append(">");
}
}
final String head = builder.toString();
this.string = head.isEmpty() ? body : "with " + head + " : " + body;
this.head = head.isEmpty() ? "" : this.string.substring(5, 5 + head.length());
this.body = head.isEmpty() ? body : this.string.substring(8 + head.length());
this.expr = expr;
this.properties = properties;
this.namespaces = ImmutableBiMap.copyOf(namespaces);
}
示例12: HierarchicalTypeStore
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
HierarchicalTypeStore(MemRepository repository, HierarchicalType hierarchicalType) throws RepositoryException {
this.hierarchicalType = (IConstructableType) hierarchicalType;
this.repository = repository;
ImmutableMap.Builder<AttributeInfo, IAttributeStore> b =
new ImmutableBiMap.Builder<>();
typeNameList = Lists.newArrayList((String) null);
ImmutableList<AttributeInfo> l = hierarchicalType.immediateAttrs;
for (AttributeInfo i : l) {
b.put(i, AttributeStores.createStore(i));
}
attrStores = b.build();
ImmutableList.Builder<HierarchicalTypeStore> b1 = new ImmutableList.Builder<>();
Set<String> allSuperTypeNames = hierarchicalType.getAllSuperTypeNames();
for (String s : allSuperTypeNames) {
b1.add(repository.getStore(s));
}
superTypeStores = b1.build();
nextPos = 0;
idPosMap = new HashMap<>();
freePositions = new ArrayList<>();
lock = new ReentrantReadWriteLock();
}
示例13: createWorkspace
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
/** Creates users workspace object based on the status and machines RAM. */
private static WorkspaceImpl createWorkspace(WorkspaceStatus status, Integer... machineRams) {
final Map<String, MachineImpl> machines = new HashMap<>(machineRams.length - 1);
final Map<String, MachineConfigImpl> machineConfigs = new HashMap<>(machineRams.length - 1);
byte i = 1;
for (Integer machineRam : machineRams) {
final String machineName = "machine_" + i++;
machines.put(machineName, createMachine(machineRam));
machineConfigs.put(machineName, createMachineConfig(machineRam));
}
return WorkspaceImpl.builder()
.setConfig(
WorkspaceConfigImpl.builder()
.setEnvironments(
ImmutableBiMap.of(ACTIVE_ENV_NAME, new EnvironmentImpl(null, machineConfigs)))
.build())
.setRuntime(new RuntimeImpl(ACTIVE_ENV_NAME, machines, null))
.setStatus(status)
.build();
}
示例14: toMd
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
@Override
protected TapFlow toMd(NeutronTapFlow flow) {
final TapFlowBuilder flowBuilder = new TapFlowBuilder();
toMdBaseAttributes(flow, flowBuilder);
if (flow.getTapFlowServiceID() != null) {
flowBuilder.setTapServiceId(toUuid(flow.getTapFlowServiceID()));
}
if (flow.getTapFlowSourcePort() != null) {
flowBuilder.setSourcePort(toUuid(flow.getTapFlowSourcePort()));
}
if (flow.getTapFlowDirection() != null) {
final ImmutableBiMap<String, Class<? extends DirectionBase>> mapper = DIRECTION_MAP.inverse();
flowBuilder.setDirection(mapper.get(flow.getTapFlowDirection()));
}
return flowBuilder.build();
}
示例15: toMd
import com.google.common.collect.ImmutableBiMap; //導入依賴的package包/類
@Override
protected Trunk toMd(NeutronTrunk trunk) {
final TrunkBuilder trunkBuilder = new TrunkBuilder();
toMdAdminAttributes(trunk, trunkBuilder);
if (trunk.getPortId() != null) {
trunkBuilder.setPortId(toUuid(trunk.getPortId()));
}
if (trunk.getSubPorts() != null) {
final List<SubPorts> subPortsList = new ArrayList<>();
final SubPortsBuilder subPortsBuilder = new SubPortsBuilder();
final ImmutableBiMap<String, Class<? extends NetworkTypeBase>> mapper = NETWORK_TYPE_MAP.inverse();
for (NeutronTrunkSubPort subPort: trunk.getSubPorts()) {
subPortsBuilder.setPortId(toUuid(subPort.getPortId()));
subPortsBuilder.setSegmentationType(mapper.get(subPort.getSegmentationType()));
subPortsBuilder.setSegmentationId(Long.valueOf(subPort.getSegmentationId()));
subPortsList.add(subPortsBuilder.build());
}
trunkBuilder.setSubPorts(subPortsList);
}
return trunkBuilder.build();
}