本文整理了Java中com.google.common.collect.MultimapBuilder
类的一些代码示例,展示了MultimapBuilder
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultimapBuilder
类的具体详情如下:
包路径:com.google.common.collect.MultimapBuilder
类名称:MultimapBuilder
[英]A builder for a multimap implementation that allows customization of the backing map and value collection implementations used in a particular multimap.
This can be used to easily configure multimap data structure implementations not provided explicitly in com.google.common.collect, for example:
ListMultimap treeListMultimap =
MultimapBuilder instances are immutable. Invoking a configuration method has no effect on the receiving instance; you must store and use the new builder instance it returns instead.
The generated multimaps are serializable if the key and value types are serializable, unless stated otherwise in one of the configuration methods.
[中]多映射实现的生成器,允许自定义特定多映射中使用的支持映射和值集合实现。
这可用于轻松配置com中未明确提供的多映射数据结构实现。谷歌。常见的收集,例如:
ListMultimap treeListMultimap =
MultimapBuilder实例是不可变的。调用配置方法对接收实例没有影响;您必须存储并使用它返回的新生成器实例。
如果键和值类型是可序列化的,则生成的多重映射是可序列化的,除非在其中一种配置方法中另有说明。
代码示例来源:origin: google/guava
public void testGenerics_gwtCompatible() {
ListMultimap
MultimapBuilder.hashKeys().arrayListValues().
SortedSetMultimap
MultimapBuilder.linkedHashKeys().treeSetValues().
SetMultimap
MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
.hashSetValues()
.
}
代码示例来源:origin: google/guava
/**
* Returns a {@code Multimap} with the specified implementation, initialized with the entries of
* {@code multimap}.
*/
public
Multimap extends K, ? extends V> multimap) {
Multimap
result.putAll(multimap);
return result;
}
代码示例来源:origin: greenaddress/GreenBits
@Override
protected Multimap
Multimap
result.put(State.UNINITIALISED, State.NEW);
result.put(State.UNINITIALISED, State.READY);
result.put(State.NEW, State.SAVE_STATE_IN_WALLET);
result.put(State.SAVE_STATE_IN_WALLET, State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER, State.READY);
result.put(State.READY, State.EXPIRED);
result.put(State.READY, State.CLOSED);
return result;
}
代码示例来源:origin: dstl/baleen
private Multimap
final Map
final Multimap
MultimapBuilder.hashKeys().arrayListValues().build();
mentions.values().forEach(m -> map.put(m.getEntityId(), m));
return map;
}
代码示例来源:origin: Swagger2Markup/swagger2markup
operatiOnsGroupedByTag= LinkedHashMultimap.create();
} else {
operatiOnsGroupedByTag= MultimapBuilder.linkedHashKeys().treeSetValues(operationOrdering).build();
logger.debug("Added path operation '{}' to tag '{}'", operation, tag);
operationsGroupedByTag.put(tag, operation);
代码示例来源:origin: dstl/baleen
private void addMetadata(JCas jCas, Document doc) {
Multimap
for (Metadata metadata : JCasUtil.select(jCas, Metadata.class)) {
String key = metadata.getKey();
if (key.contains(".")) { // Field names can't contain a "." in Mongo, so replace with a _
key = key.replaceAll("\\.", "_");
}
meta.put(key, metadata.getValue());
}
doc.append(FIELD_METADATA, meta.asMap());
}
代码示例来源:origin: com.torodb.torod.backends/common
.enumKeys(ScalarType.class)
.hashSetValues()
.build();
byTypeValues.put(value.getType(), value);
if (byTypeValues.isEmpty()) {
result = Collections.emptyList();
} else {
代码示例来源:origin: imperial-crystalline-recursion/abtestgen
private void generateViewTests(Set extends TypeElement> annotations,
RoundEnvironment roundEnv) {
Multimap
MultimapBuilder.linkedHashKeys().arrayListValues().build();
getTextTests(roundEnv, viewTestMap);
getResTests(roundEnv, viewTestMap);
Set
String[] keys = strings.toArray(new String[strings.size()]);
for (String key : keys) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, key);
createTest(key, viewTestMap.get(key));
}
}
代码示例来源:origin: prestodb/presto
idxConstraintRangePairs.asMap().forEach((key, value) -> executor.submit(() -> {
long cardinality = getColumnCardinality(schema, table, auths, key.getFamily(), key.getQualifier(), value);
LOG.debug("Cardinality for column %s is %s", key.getName(), cardinality);
ListMultimap
try {
boolean earlyReturn = false;
int numTasks = idxConstraintRangePairs.asMap().entrySet().size();
do {
代码示例来源:origin: google/guava
public void testFlatteningToMultimap() {
Collector
Multimaps.flatteningToMultimap(
str -> str.charAt(0),
str -> str.substring(1).chars().mapToObj(c -> (char) c),
MultimapBuilder.linkedHashKeys().arrayListValues()::build);
BiPredicate
Equivalence.equals()
.onResultOf((Multimap, ?> mm) -> ImmutableList.copyOf(mm.asMap().entrySet()))
.and(Equivalence.equals());
ListMultimap
MultimapBuilder.linkedHashKeys().arrayListValues().build();
ListMultimap
MultimapBuilder.linkedHashKeys().arrayListValues().build();
filled.putAll('b', Arrays.asList('a', 'n', 'a', 'n', 'a'));
filled.putAll('a', Arrays.asList('p', 'p', 'l', 'e'));
filled.putAll('c', Arrays.asList('a', 'r', 'r', 'o', 't'));
filled.putAll('a', Arrays.asList('s', 'p', 'a', 'r', 'a', 'g', 'u', 's'));
filled.putAll('c', Arrays.asList('h', 'e', 'r', 'r', 'y'));
CollectorTester.of(collector, equivalence)
.expectCollects(empty)
.expectCollects(filled, "banana", "apple", "carrot", "asparagus", "cherry");
}
代码示例来源:origin: glowroot/glowroot
synchronized void updateCache() {
Multimap
for (ClassLoader loader : getKnownClassLoaders()) {
updateCache(loader, newClassNameLocations);
}
updateCacheWithClasspathClasses(newClassNameLocations);
updateCacheWithBootstrapClasses(newClassNameLocations);
if (!newClassNameLocations.isEmpty()) {
// multimap that sorts keys and de-dups values while maintains value ordering
SetMultimap
MultimapBuilder.treeKeys().linkedHashSetValues().build();
newMap.putAll(classNameLocations);
newMap.putAll(newClassNameLocations);
classNameLocatiOns= ImmutableMultimap.copyOf(newMap);
}
}
代码示例来源:origin: google/guava
/** Uses a hash table to map keys to value collections. */
public static MultimapBuilderWithKeys hashKeys() {
return hashKeys(DEFAULT_EXPECTED_KEYS);
}
代码示例来源:origin: google/guava
@GwtIncompatible // serialization
public void testSerialization() throws Exception {
for (MultimapBuilderWithKeys> builderWithKeys :
ImmutableList.of(
MultimapBuilder.hashKeys(),
MultimapBuilder.linkedHashKeys(),
MultimapBuilder.treeKeys(),
MultimapBuilder.enumKeys(RoundingMode.class))) {
for (MultimapBuilder, ?> builder :
ImmutableList.of(
builderWithKeys.arrayListValues(),
builderWithKeys.linkedListValues(),
builderWithKeys.hashSetValues(),
builderWithKeys.linkedHashSetValues(),
builderWithKeys.treeSetValues(),
builderWithKeys.enumSetValues(RoundingMode.class))) {
/*
* Temporarily inlining SerializableTester here for obscure internal reasons.
*/
reserializeAndAssert(builder.build());
}
}
}
代码示例来源:origin: google/guava
The collections returned by {@link Multimap#keySet()}, {@link Multimap#keys()}, and {@link/**
* Uses a hash table to map keys to value collections.
*
*
* Multimap#asMap()} will iterate through the keys in the order that they were first added to the
* multimap, save that if all values associated with a key are removed and then the key is added
* back into the multimap, that key will come last in the key iteration order.
*/
public static MultimapBuilderWithKeys linkedHashKeys() {
return linkedHashKeys(DEFAULT_EXPECTED_KEYS);
}
代码示例来源:origin: google/guava
The collections returned by {@link Multimap#keySet()}, {@link Multimap#keys()}, and {@link For all multimaps generated by the resulting builder, the {@link Multimap#keySet()} can be/**
* Uses a naturally-ordered {@link TreeMap} to map keys to value collections.
*
*
* Multimap#asMap()} will iterate through the keys in sorted order.
*
*
* safely cast to a {@link java.util.SortedSet}, and the {@link Multimap#asMap()} can safely be
* cast to a {@link java.util.SortedMap}.
*/
@SuppressWarnings("rawtypes")
public static MultimapBuilderWithKeys
return treeKeys(Ordering.natural());
}
代码示例来源:origin: com.atlassian.oai/swagger-request-validator-core
static Multimap
return caseSensitive ? MultimapBuilder.hashKeys().arrayListValues().build() :
MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).arrayListValues().build();
}
代码示例来源:origin: google/guava
@Override
public
Multimap extends K, ? extends V> multimap) {
return (ListMultimap
}
}
代码示例来源:origin: HashEngineering/dashj
@Override
protected Multimap
Multimap
result.put(State.UNINITIALISED, State.NEW);
result.put(State.UNINITIALISED, State.READY);
result.put(State.NEW, State.SAVE_STATE_IN_WALLET);
result.put(State.SAVE_STATE_IN_WALLET, State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER, State.READY);
result.put(State.READY, State.EXPIRED);
result.put(State.READY, State.CLOSED);
return result;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testSerializeStringKey() throws Exception {
Multimap
map.put("a", 1);
map.put("a", 2);
map.put("a", 3);
String json = mapper.writer().writeValueAsString(map);
assertEquals(json, "{\"a\":[1,2,3]}");
}
代码示例来源:origin: google/j2objc
/** Uses a hash table to map keys to value collections. */
public static MultimapBuilderWithKeys hashKeys() {
return hashKeys(DEFAULT_EXPECTED_KEYS);
}