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


Java ImmutableBiMap.builder方法代碼示例

本文整理匯總了Java中com.google.common.collect.ImmutableBiMap.builder方法的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableBiMap.builder方法的具體用法?Java ImmutableBiMap.builder怎麽用?Java ImmutableBiMap.builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.ImmutableBiMap的用法示例。


在下文中一共展示了ImmutableBiMap.builder方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: transform

import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
/**
 * Transform all the original data in the specified mapping, using this mapping.
 *
 * This is useful for {@link #createRenamingMappings(UnaryOperator, Function, Function)},
 * since renaming mappings have no 'original' data of their own, and so can't be directly output to a file.
 * The returned mapping data is guaranteed to have the same originals as the data of the old mapping data.
 *
 * @return the transformed data
 */
default Mappings transform(Mappings original) {
    ImmutableBiMap.Builder<JavaType, JavaType> types = ImmutableBiMap.builder();
    ImmutableBiMap.Builder<MethodData, MethodData> methods = ImmutableBiMap.builder();
    ImmutableBiMap.Builder<FieldData, FieldData> fields = ImmutableBiMap.builder();
    original.classes().forEach(originalType -> {
        JavaType newType = this.getNewType(originalType);
        types.put(originalType, newType);
    });
    original.methods().forEach(originalMethodData -> {
        MethodData newMethodData = this.getNewMethod(originalMethodData);
        methods.put(originalMethodData, newMethodData);
    });
    original.fields().forEach(originalFieldData -> {
        FieldData newFieldData = this.getNewField(originalFieldData);
        fields.put(originalFieldData, newFieldData);
    });
    return ImmutableMappings.create(types.build(), methods.build(), fields.build());
}
 
開發者ID:Techcable,項目名稱:SrgLib,代碼行數:28,代碼來源:Mappings.java

示例7: 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());
        }
        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:HATB0T,項目名稱:RuneCraftery,代碼行數:21,代碼來源:LoadController.java

示例8: getHeaderColumns

import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
private ImmutableBiMap<UnosDataHeader, Integer> getHeaderColumns(
    CSVRecord headerRow) {
  ImmutableBiMap.Builder<UnosDataHeader, Integer> ans = ImmutableBiMap
      .builder();
  for (int i = 0; i < headerRow.size(); i++) {
    String header = headerRow.get(i);
    if (dataHeaderNames.inverse().containsKey(header)) {
      ans.put(dataHeaderNames.inverse().get(header), i);
    }
  }
  ImmutableBiMap<UnosDataHeader, Integer> ansBuilt = ans.build();
  if (ansBuilt.size() != dataHeaderNames.size()) {
    throw new RuntimeException("Expected "
        + dataHeaderNames.size()
        + " headers but found: "
        + ansBuilt.size()
        + ".  Values: "
        + ansBuilt
        + ", Missing: "
        + Sets.difference(EnumSet.allOf(UnosDataHeader.class),
            ansBuilt.keySet()));
  }
  return ansBuilt;
}
 
開發者ID:rma350,項目名稱:kidneyExchange,代碼行數:25,代碼來源:UnosParseData.java

示例9: UnosData

import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public UnosData(
    ImmutableSet<UnosExchangeUnit> altruisticDonors,
    ImmutableSet<UnosExchangeUnit> pairs,
    DirectedSparseMultigraph<UnosExchangeUnit, UnosDonorEdge> feasibleTransplants) {
  super();
  this.altruisticDonors = altruisticDonors;
  this.pairs = pairs;
  this.feasibleTransplants = feasibleTransplants;
  ImmutableBiMap.Builder<String, UnosExchangeUnit> nodeIdBuilder = ImmutableBiMap
      .builder();
  for (UnosExchangeUnit alt : altruisticDonors) {
    nodeIdBuilder.put("a" + alt.getDonors().get(0).getId(), alt);
  }
  for (UnosExchangeUnit paired : pairs) {
    nodeIdBuilder.put("p" + paired.getPatient().getId(), paired);
  }
  this.nodeIds = nodeIdBuilder.build();
  ImmutableBiMap.Builder<String, UnosDonorEdge> edgeIdBuilder = ImmutableBiMap
      .builder();
  for (UnosDonorEdge edge : feasibleTransplants.getEdges()) {
    String id = "e" + edge.getDonor().getId() + "-"
        + feasibleTransplants.getDest(edge).getPatient().getId();
    edgeIdBuilder.put(id, edge);
  }
  this.edgeIds = edgeIdBuilder.build();
}
 
開發者ID:rma350,項目名稱:kidneyExchange,代碼行數:27,代碼來源:UnosData.java

示例10: CompiledTemplateRegistry

import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
CompiledTemplateRegistry(TemplateRegistry registry) {
  Map<String, Optional<SanitizedContentKind>> deltemplateNameToContentKind = new HashMap<>();
  ImmutableBiMap.Builder<String, CompiledTemplateMetadata> templateToMetadata =
      ImmutableBiMap.builder();
  ImmutableBiMap.Builder<String, CompiledTemplateMetadata> classToMetadata =
      ImmutableBiMap.builder();
  ImmutableSet.Builder<String> delegateTemplateNames = ImmutableSet.builder();
  for (TemplateNode template : registry.getAllTemplates()) {
    CompiledTemplateMetadata metadata =
        CompiledTemplateMetadata.create(template.getTemplateName(), template);
    templateToMetadata.put(template.getTemplateName(), metadata);
    classToMetadata.put(metadata.typeInfo().className(), metadata);
    if (template instanceof TemplateDelegateNode) {
      delegateTemplateNames.add(template.getTemplateName());
      // all delegates are guaranteed to have the same content kind by the
      // checkdelegatesvisitor
      deltemplateNameToContentKind.put(
          ((TemplateDelegateNode) template).getDelTemplateName(),
          Optional.fromNullable(template.getContentKind()));
    }
  }
  this.templateNameToMetadata = templateToMetadata.build();
  this.classNameToMetadata = classToMetadata.build();
  this.deltemplateNameToContentKind = ImmutableMap.copyOf(deltemplateNameToContentKind);
  this.delegateTemplateNames = delegateTemplateNames.build();
}
 
開發者ID:google,項目名稱:closure-templates,代碼行數:27,代碼來源:CompiledTemplateRegistry.java

示例11: getObfuscatedToOriginalMapping

import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public BiMap<String, String> getObfuscatedToOriginalMapping() {
  if (nameMapping == null) {
    ImmutableBiMap.Builder<String, String> builder = ImmutableBiMap.builder();
    for (String name : classNameMappings.keySet()) {
      builder.put(name, classNameMappings.get(name).originalName);
    }
    nameMapping = builder.build();
  }
  return nameMapping;
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:11,代碼來源:ClassNameMapper.java

示例12: copyWithFilteredResponses

import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public ResponseLinking copyWithFilteredResponses(final Predicate<Response> toKeepCondition) {
  final Set<Response> newIncompletes = Sets.filter(incompleteResponses(), toKeepCondition);
  final ImmutableSet.Builder<ResponseSet> newResponseSetsB = ImmutableSet.builder();
  final ImmutableBiMap.Builder<String, ResponseSet> responseSetsIdB = ImmutableBiMap.builder();
  // to account for ResponseSets merging due to lost annotation
  final Set<ResponseSet> alreadyAdded = Sets.newHashSet();
  for (final ResponseSet responseSet : responseSets()) {
    final ImmutableSet<Response> okResponses = FluentIterable.from(responseSet.asSet())
        .filter(toKeepCondition).toSet();
    if (!okResponses.isEmpty()) {
      final ResponseSet newResponseSet = ResponseSet.from(okResponses);
      if(alreadyAdded.contains(newResponseSet)) {
        continue;
      }
      alreadyAdded.add(newResponseSet);
      newResponseSetsB.add(newResponseSet);
      if (responseSetIds().isPresent()) {
        responseSetsIdB.put(responseSetIds().get().inverse().get(responseSet), newResponseSet);
      }
    }
  }

  final ImmutableSet<ResponseSet> newResponseSets = newResponseSetsB.build();
  final ResponseLinking.Builder ret = ResponseLinking.builder().docID(docID())
      .responseSets(newResponseSets).incompleteResponses(newIncompletes);
  if (responseSetIds().isPresent()) {
    ret.responseSetIds(responseSetsIdB.build());
  }
  return ret.build();
}
 
開發者ID:isi-nlp,項目名稱:tac-kbp-eal,代碼行數:31,代碼來源:_ResponseLinking.java

示例13: create

import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
@Override
protected BiMap<String, String> create(Entry<String, String>[] entries) {
  ImmutableBiMap.Builder<String, String> builder = ImmutableBiMap.builder();
  for (Entry<String, String> entry : entries) {
    builder.put(entry.getKey(), entry.getValue());
  }
  return builder.build();
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:9,代碼來源:BiMapGenerators.java

示例14: setupLoadOnly

import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public void setupLoadOnly(String deobfFileName, boolean loadAll)
{
    try
    {
        File mapData = new File(deobfFileName);
        LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData));
        CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
        List<String> srgList = srgSource.readLines();
        rawMethodMaps = Maps.newHashMap();
        rawFieldMaps = Maps.newHashMap();
        Builder<String, String> builder = ImmutableBiMap.builder();
        Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
        for (String line : srgList)
        {
            String[] parts = Iterables.toArray(splitter.split(line),String.class);
            String typ = parts[0];
            if ("CL".equals(typ))
            {
                parseClass(builder, parts);
            }
            else if ("MD".equals(typ) && loadAll)
            {
                parseMethod(parts);
            }
            else if ("FD".equals(typ) && loadAll)
            {
                parseField(parts);
            }
        }
        classNameBiMap = builder.build();
    }
    catch (IOException ioe)
    {
        FMLRelaunchLog.log(Level.ERROR, "An error occurred loading the deobfuscation map data", ioe);
    }
    methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
    fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());

}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:40,代碼來源:FMLDeobfuscatingRemapper.java

示例15: getRpcMethodToSchemaPath

import com.google.common.collect.ImmutableBiMap; //導入方法依賴的package包/類
public ImmutableBiMap<Method, SchemaPath> getRpcMethodToSchemaPath(final Class<? extends RpcService> key) {
    final Module module = getModuleBlocking(key);
    final ImmutableBiMap.Builder<Method, SchemaPath> ret = ImmutableBiMap.<Method, SchemaPath>builder();
    try {
        for (final RpcDefinition rpcDef : module.getRpcs()) {
            final Method method = findRpcMethod(key, rpcDef);
            ret.put(method, rpcDef.getPath());
        }
    } catch (final NoSuchMethodException e) {
        throw new IllegalStateException("Rpc defined in model does not have representation in generated class.", e);
    }
    return ret.build();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:14,代碼來源:BindingToNormalizedNodeCodec.java


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