当前位置: 首页>>代码示例>>Java>>正文


Java BiMap.get方法代码示例

本文整理汇总了Java中com.google.common.collect.BiMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java BiMap.get方法的具体用法?Java BiMap.get怎么用?Java BiMap.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.BiMap的用法示例。


在下文中一共展示了BiMap.get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: from

import com.google.common.collect.BiMap; //导入方法依赖的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);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:26,代码来源:ClassRenamingMapper.java

示例2: modifyTypes

import com.google.common.collect.BiMap; //导入方法依赖的package包/类
/** Applies the supplied modifications to the GraphQLTypes. */
private static BiMap<String, GraphQLType> modifyTypes(
    BiMap<String, GraphQLType> mapping,
    ImmutableListMultimap<String, TypeModification> modifications) {
  BiMap<String, GraphQLType> result = HashBiMap.create(mapping.size());
  for (String key : mapping.keySet()) {
    if (mapping.get(key) instanceof GraphQLObjectType) {
      GraphQLObjectType val = (GraphQLObjectType) mapping.get(key);
      if (modifications.containsKey(key)) {
        for (TypeModification modification : modifications.get(key)) {
          val = modification.apply(val);
        }
      }
      result.put(key, val);
    } else {
      result.put(key, mapping.get(key));
    }
  }
  return result;
}
 
开发者ID:google,项目名称:rejoiner,代码行数:21,代码来源:ProtoRegistry.java

示例3: translate

import com.google.common.collect.BiMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static <T extends Entry> T translate(T in, BiMap<ClassEntry,ClassEntry> map) {
	if (in instanceof FieldEntry) {
		return (T)new FieldEntry(
			map.get(in.getClassEntry()),
			in.getName(),
			translate(((FieldEntry)in).getType(), map)
		);
	} else if (in instanceof MethodEntry) {
		return (T)new MethodEntry(
			map.get(in.getClassEntry()),
			in.getName(),
			translate(((MethodEntry)in).getSignature(), map)
		);
	} else if (in instanceof ConstructorEntry) {
		return (T)new ConstructorEntry(
			map.get(in.getClassEntry()),
			translate(((ConstructorEntry)in).getSignature(), map)
		);
	}
	throw new Error("Unhandled entry type: " + in.getClass());
}
 
开发者ID:cccssw,项目名称:enigma-vk,代码行数:23,代码来源:MappingsConverter.java

示例4: onSubstituteActivated

import com.google.common.collect.BiMap; //导入方法依赖的package包/类
@Override
public void onSubstituteActivated(Map<ResourceLocation, ?> slaveset, Block original, Block replacement, ResourceLocation name)
{
    final BiMap<Block, Item> blockItemMap = (BiMap<Block, Item>)slaveset.get(BLOCK_TO_ITEM);
    if (blockItemMap.containsKey(original))
    {
        Item i = blockItemMap.get(original);
        if (i instanceof ItemBlock)
        {
            try
            {
                FinalFieldHelper.setField(blockField, i, replacement);
            }
            catch (Exception e)
            {
                throw Throwables.propagate(e);
            }
        }
        blockItemMap.forcePut(replacement,i);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:GameData.java

示例5: resolveKey

import com.google.common.collect.BiMap; //导入方法依赖的package包/类
/**
 * Resolve the actual key that would be used if the given key and value
 * were inserted into the map in its current state, but do not actually
 * make any changes to the map.
 */
public K resolveKey(K key, V value) {
    final BiMap<K, V> delegate = delegate();
    for(int tries = 0; tries < limit; tries++) {
        final V existing = delegate.get(key);
        if(existing == null || existing.equals(value)) {
            return key;
        }
        key = uniquifier.apply(key);
    }
    throw new IllegalArgumentException("Failed to generate a unique key after " + limit + " attempts");
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:ConflictResolvingMap.java

示例6: testInverseDate

import com.google.common.collect.BiMap; //导入方法依赖的package包/类
/**
 * inverse() BiMap的核心功能inverse,inverse后返回新的BiMap,此时key-value做了翻转
 * inverse() 不改变原来BiMap,而是新生成一个
 * 此时k,v 的存储没有相同的数据冲突
 */
@Test
public void testInverseDate() {
    BiMap<String, String> biMap = HashBiMap.create();
    biMap.put("1233", "haoc");
    biMap.put("1244", "jim");
    biMap.put("1255", "jack");

    // k->v
    String v1 = biMap.get("1233");
    String v2 = biMap.get("1244");
    String v3 = biMap.get("1255");
    System.out.println(v1);
    System.out.println(v2);
    System.out.println(v3);

    // 做键值翻转
    BiMap<String, String> inverseBiMap = biMap.inverse();

    // v->k
    String k1 = inverseBiMap.get("haoc");
    String k2 = inverseBiMap.get("jim");
    String k3 = inverseBiMap.get("jack");
    System.out.println(k1);
    System.out.println(k2);
    System.out.println(k3);
}
 
开发者ID:cbooy,项目名称:cakes,代码行数:32,代码来源:HashBiMapDemo.java

示例7: fromYang

import com.google.common.collect.BiMap; //导入方法依赖的package包/类
@Override
public String fromYang(final String enumClass, final String enumYangValue) {
    Preconditions.checkState(this.bindingContextProvider != null, "Binding context provider was not set yet");
    final BiMap<String, String> enumMapping = this.bindingContextProvider.getEnumMapping(enumClass);
    final String javaName = enumMapping.get(enumYangValue);
    return Preconditions.checkNotNull(javaName,
            "Unable to resolve enum value %s for enum class %s with assumed enum mapping: %s", enumYangValue,
            enumClass, enumMapping);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:YangStoreSnapshot.java

示例8: getSystemShortName

import com.google.common.collect.BiMap; //导入方法依赖的package包/类
/**
 * Returns game system's abbreviated name.
 * <p>
 * For example, calling this method with the argument "PlayStation 4" will return
 * "PS4".
 *
 * @param system
 *            full system display name.
 * @return abbreviated system name.
 */
public static String getSystemShortName(String systemLongName) {
    if (systemNameMap.containsValue(systemLongName)) {
        BiMap<String, String> invSystemNameMap = systemNameMap.inverse();
        return invSystemNameMap.get(systemLongName);
    } else {
        return systemLongName;
    }
}
 
开发者ID:Stevoisiak,项目名称:Virtual-Game-Shelf,代码行数:19,代码来源:GameShelf.java

示例9: lookup

import com.google.common.collect.BiMap; //导入方法依赖的package包/类
/**
 * Looks up the specified input value to the corresponding value with the specified map.
 *
 * @param map   bidirectional mapping
 * @param input input type
 * @param cls   class of output value
 * @param <I>   type of input value
 * @param <O>   type of output value
 * @return the corresponding value stored in the specified map
 */
private static <I, O> O lookup(BiMap<I, O> map, I input, Class<O> cls) {
    if (!map.containsKey(input)) {
        throw new RuntimeException(
                String.format("No mapping found for %s when converting to %s",
                        input, cls.getName()));
    }
    return map.get(input);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OpenFlowControlMessageMapper.java

示例10: lookup

import com.google.common.collect.BiMap; //导入方法依赖的package包/类
/**
 * Looks up the specified input value to the corresponding value with the specified map.
 *
 * @param map bidirectional mapping
 * @param input input value
 * @param cls class of output value
 * @param <I> type of input value
 * @param <O> type of output value
 * @return the corresponding value stored in the specified map
 */
private static <I, O> O lookup(BiMap<I, O> map, I input, Class<O> cls) {
    if (!map.containsKey(input)) {
        throw new RuntimeException(
                String.format("No mapping found for %s when converting to %s", input, cls.getName()));
    }

    return map.get(input);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OpenFlowDeviceValueMapper.java

示例11: lookup

import com.google.common.collect.BiMap; //导入方法依赖的package包/类
/**
 * Looks up the specified input value to the corresponding value with the specified map.
 *
 * @param map bidirectional mapping
 * @param input input value
 * @param cls class of output value
 * @param <I> type of input value
 * @param <O> type of output value
 * @return the corresponding value stored in the specified map
 * @throws NoMappingFoundException if no corresponding value is found
 */
private static <I, O> O lookup(BiMap<I, O> map, I input, Class<O> cls) {
    if (!map.containsKey(input)) {
        throw new NoMappingFoundException(input, cls);
    }

    return map.get(input);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OpenFlowValueMapper.java


注:本文中的com.google.common.collect.BiMap.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。