当前位置: 首页>>代码示例>>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;未经允许,请勿转载。