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


Java HashMultimap.put方法代码示例

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


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

示例1: test_for_multimap

import com.google.common.collect.HashMultimap; //导入方法依赖的package包/类
public void test_for_multimap() throws Exception {
    HashMultimap map = HashMultimap.create();
    map.put("name", "a");
    map.put("name", "b");

    String json = JSON.toJSONString(map);
    assertEquals("{\"name\":[\"a\",\"b\"]}", json);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:HashMultimapTest.java

示例2: createTestLocationMapping

import com.google.common.collect.HashMultimap; //导入方法依赖的package包/类
/**
 * Creates a mapping between the container module URI and the actual URIs. Consider cases when the list contains two
 * locations URIs from two methods in the same class Then this method will return with multimap where the single key
 * is the location to the container module and the value is the two method URIs.
 */
private HashMultimap<URI, URI> createTestLocationMapping(List<URI> testLocations) {
	HashMultimap<URI, URI> moduleUris2testUris = HashMultimap.create();
	for (final URI testLocation : testLocations) {
		moduleUris2testUris.put(testLocation.trimFragment(), testLocation);
	}
	return moduleUris2testUris;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:13,代码来源:TestDiscoveryHelper.java

示例3: addIndex

import com.google.common.collect.HashMultimap; //导入方法依赖的package包/类
private void addIndex(String tableName, Attribute attribute) {
    HashMultimap hash = HashMultimap.create();
    TreeMultimap tree = TreeMultimap.create();
    countBlocks = 1;
    inputStream = nextBlock(tableName);
    do {
        int countRows = 0;
        while (countRows < blockSize && inputStream.hasNext()) {
            String row = inputStream.nextLine();
            String[] tempRow = row.split(DEFAULT_SEPARATOR);
            Object key = tempRow[attribute.getIndex()];
            if (attribute.getType().equals("Integer")) {
                key = Integer.parseInt((String) key);
            } else if (attribute.getType().equals("Double")) {
                key = Double.parseDouble((String) key);
            }
            String blockLine = (countBlocks - 1) + "," + countRows;
            if (attribute.getScan().equals("hash")) {
                hash.put(key, blockLine);
            } else {
                tree.put(key, blockLine);
            }
            countRows++;
        }
        inputStream = nextBlock(tableName);
    } while (inputStream != null);
    if (attribute.getScan().equals("hash")) {
        hashIndexes.get(tableName).put(attribute.getColumnName(), hash);
    } else if (attribute.getType().equals("Integer") || attribute.getType().equals("Double")) {
        btreeNumberIndexes.get(tableName).put(attribute.getColumnName(), tree);
    }
    else {
        btreeIndexes.get(tableName).put(attribute.getColumnName(), tree);
    }
    this.close();
}
 
开发者ID:andcastillo,项目名称:fdp2017,代码行数:37,代码来源:Indexer.java

示例4: parseFiles

import com.google.common.collect.HashMultimap; //导入方法依赖的package包/类
/** Given a list of source files, creates a graph of their class level dependencies */
private static void parseFiles(
    ImmutableList<Path> absoluteSourceFilePaths,
    ImmutableList<Path> contentRoots,
    ImmutableSet<Path> oneRulePerPackageRoots,
    ImmutableSet.Builder<String> unresolvedClassNames,
    MutableGraph<String> classToClass,
    ImmutableMap.Builder<String, String> classToFile,
    ImmutableMap.Builder<String, String> fileToRuleKind)
    throws IOException {
  HashMultimap<Path, String> dirToClass = HashMultimap.create();
  for (Path srcFilePath : absoluteSourceFilePaths) {
    ReferencedClassesParser parser =
        new ReferencedClassesParser(
            srcFilePath.getFileName().toString(),
            new String(readAllBytes(srcFilePath), UTF_8),
            contentRoots);
    checkState(parser.isSuccessful);
    if (Strings.isNullOrEmpty(parser.fullyQualifiedClassName)) {
      // The file doesn't contain any classes, skip it. This happens for package-info.java files.
      continue;
    }
    String qualifiedSrc = stripInnerClassFromName(parser.fullyQualifiedClassName);
    dirToClass.put(srcFilePath.getParent(), parser.fullyQualifiedClassName);

    boolean hasEdges = false;
    classToFile.put(qualifiedSrc, srcFilePath.toString());
    for (QualifiedName qualifiedDst : parser.qualifiedTopLevelNames) {
      if (!qualifiedSrc.equals(qualifiedDst.value())) {
        classToClass.putEdge(qualifiedSrc, qualifiedDst.value());
        hasEdges = true;
      }
    }

    for (SimpleName name : parser.unresolvedClassNames) {
      unresolvedClassNames.add(name.value());
    }

    fileToRuleKind.put(
        srcFilePath.toString(),
        decideRuleKind(
            parser, hasEdges ? classToClass.adjacentNodes(qualifiedSrc) : ImmutableSet.of()));
  }

  // Put classes defined in 'oneRulePerPackageRoots' on cycles.
  dirToClass
      .asMap()
      .forEach(
          (path, classes) -> {
            if (any(oneRulePerPackageRoots, p -> path.startsWith(p))) {
              putOnCycle(classes, classToClass);
            }
          });
}
 
开发者ID:bazelbuild,项目名称:BUILD_file_generator,代码行数:55,代码来源:JavaSourceFileParser.java

示例5: generateHashMultimap

import com.google.common.collect.HashMultimap; //导入方法依赖的package包/类
@Generates private static <K, V> HashMultimap<K, V> generateHashMultimap(K key, V value) {
  HashMultimap<K, V> multimap = HashMultimap.create();
  multimap.put(key, value);
  return multimap;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:6,代码来源:FreshValueGenerator.java

示例6: addInformation

import com.google.common.collect.HashMultimap; //导入方法依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" })
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isComplex) {
	if (stack.getItemDamage() == 0)
		return;

	List<PotionEffect> effects = getEffects(stack);
	HashMultimap<String, AttributeModifier> attributes = HashMultimap.create();

	if (effects == null || effects.isEmpty()) {
		String s = StatCollector.translateToLocal("potion.empty").trim();
		list.add(EnumChatFormatting.GRAY + s);
	} else
		for (PotionEffect potioneffect : effects) {
			String s1 = StatCollector.translateToLocal(potioneffect.getEffectName()).trim();
			Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
			Map<IAttribute, AttributeModifier> map = potion.func_111186_k();

			if (map != null && map.size() > 0)
				for (Entry<IAttribute, AttributeModifier> entry : map.entrySet()) {
					AttributeModifier attributemodifier = entry.getValue();
					AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.func_111183_a(potioneffect.getAmplifier(), attributemodifier), attributemodifier.getOperation());
					attributes.put(entry.getKey().getAttributeUnlocalizedName(), attributemodifier1);
				}

			if (potioneffect.getAmplifier() > 0)
				s1 = s1 + " " + StatCollector.translateToLocal("potion.potency." + potioneffect.getAmplifier()).trim();
			if (potioneffect.getDuration() > 20)
				s1 = s1 + " (" + Potion.getDurationString(potioneffect) + ")";

			if (potion.isBadEffect())
				list.add(EnumChatFormatting.RED + s1);
			else
				list.add(EnumChatFormatting.GRAY + s1);
		}

	if (!attributes.isEmpty()) {
		list.add("");
		list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("potion.effects.whenDrank"));

		for (Entry<String, AttributeModifier> entry1 : attributes.entries()) {
			AttributeModifier attributemodifier2 = entry1.getValue();
			double d0 = attributemodifier2.getAmount();
			double d1;

			if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2)
				d1 = attributemodifier2.getAmount();
			else
				d1 = attributemodifier2.getAmount() * 100.0D;

			if (d0 > 0.0D)
				list.add(EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier2.getOperation(), new Object[] { ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + entry1.getKey()) }));
			else if (d0 < 0.0D) {
				d1 *= -1.0D;
				list.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted("attribute.modifier.take." + attributemodifier2.getOperation(), new Object[] { ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + entry1.getKey()) }));
			}
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:61,代码来源:LingeringPotion.java


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