當前位置: 首頁>>代碼示例>>Java>>正文


Java ImmutableBiMap類代碼示例

本文整理匯總了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();
}
 
開發者ID:alexandrage,項目名稱:CauldronGit,代碼行數:26,代碼來源:LoadController.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:ExtraCollection.java

示例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);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:26,代碼來源:ClassRenamingMapper.java

示例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();
}
 
開發者ID:isi-nlp,項目名稱:tac-kbp-eal,代碼行數:20,代碼來源:QueryResponseFromERE.java

示例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));
}
 
開發者ID:google,項目名稱:rejoiner,代碼行數:25,代碼來源:GqlInputConverter.java

示例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);
}
 
開發者ID:cbooy,項目名稱:cakes,代碼行數:31,代碼來源:HashBiMapDemo.java

示例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();
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:26,代碼來源:LoadController.java

示例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;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:20,代碼來源:ModuleShardBackendResolver.java

示例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();
}
 
開發者ID:CardinalDevelopment,項目名稱:Cardinal,代碼行數:22,代碼來源:ModuleRegistry.java

示例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;
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:26,代碼來源:LanternBlockState.java

示例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);
}
 
開發者ID:dkmfbk,項目名稱:knowledgestore,代碼行數:23,代碼來源:XPath.java

示例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();
}
 
開發者ID:apache,項目名稱:incubator-atlas,代碼行數:26,代碼來源:HierarchicalTypeStore.java

示例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();
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:21,代碼來源:RamResourceUsageTrackerTest.java

示例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();
}
 
開發者ID:opendaylight,項目名稱:neutron,代碼行數:18,代碼來源:NeutronTapFlowInterface.java

示例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();
}
 
開發者ID:opendaylight,項目名稱:neutron,代碼行數:22,代碼來源:NeutronTrunkInterface.java


注:本文中的com.google.common.collect.ImmutableBiMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。