當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。