本文整理汇总了Java中com.google.common.collect.ImmutableMultimap.of方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableMultimap.of方法的具体用法?Java ImmutableMultimap.of怎么用?Java ImmutableMultimap.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableMultimap
的用法示例。
在下文中一共展示了ImmutableMultimap.of方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: combine
import com.google.common.collect.ImmutableMultimap; //导入方法依赖的package包/类
public static <K, V> Multimap<K, V> combine(Iterable<Multimap<K, V>> maps) {
Multimap<K, V> singleton = null;
ImmutableMultimap.Builder<K, V> builder = null;
for(Multimap<K, V> map : maps) {
if(!map.isEmpty()) {
if(singleton == null) {
singleton = map;
} else {
if(builder == null) {
builder = ImmutableMultimap.builder();
}
builder.putAll(singleton);
builder.putAll(map);
}
}
}
if(builder != null) {
return builder.build();
} else if(singleton != null) {
return singleton;
} else {
return ImmutableMultimap.of();
}
}
示例2: getCollaboratorsForItemIds
import com.google.common.collect.ImmutableMultimap; //导入方法依赖的package包/类
@Override
@Transactional(propagation = Propagation.MANDATORY)
public Multimap<Long, String> getCollaboratorsForItemIds(Collection<Long> itemIds)
{
if( itemIds.isEmpty() )
{
return ImmutableMultimap.of();
}
List<Object[]> attachments = getHibernateTemplate().findByNamedParam(
"select c, i.id from Item i join i.collaborators c where i.id in (:items)", "items", itemIds);
ListMultimap<Long, String> multiMap = ArrayListMultimap.create();
for( Object[] attachmentRow : attachments )
{
multiMap.put((Long) attachmentRow[1], (String) attachmentRow[0]);
}
return multiMap;
}
示例3: pathPropertiesOfAsMultimap
import com.google.common.collect.ImmutableMultimap; //导入方法依赖的package包/类
public static ImmutableMultimap<String, Object> pathPropertiesOfAsMultimap(Blob blob, Function<String, Collection<String>> pathPropertyMapping, Path path, PropertyCollectionResolver propertyResolver) {
ImmutableList<String> pathProperties = path.propertyNamesWithoutPage();
ImmutableMap<String, ImmutableSet<?>> blopPathPropertyMap = pathProperties.stream()
.map(p -> Pair.<String, ImmutableSet<?>>of(p, propertyOf(blob, pathPropertyMapping, propertyResolver, p)))
.filter(pair -> !pair.b().isEmpty())
.collect(ImmutableMap.toImmutableMap(Pair::a, Pair::b));
if (blopPathPropertyMap.keySet().size()<pathProperties.size()) {
return ImmutableMultimap.of();
}
Builder<String, Object> multiMapBuilder = ImmutableMultimap.builder();
blopPathPropertyMap.forEach((key, values) -> {
multiMapBuilder.putAll(key, values);
});
return multiMapBuilder.build();
}
示例4: generateImmutableMultimap
import com.google.common.collect.ImmutableMultimap; //导入方法依赖的package包/类
@Generates private static <K, V> ImmutableMultimap<K, V> generateImmutableMultimap(
K key, V value) {
return ImmutableMultimap.of(key, value);
}
示例5: ListenerMapGeneration
import com.google.common.collect.ImmutableMultimap; //导入方法依赖的package包/类
ListenerMapGeneration() {
typeToListeners = ImmutableMultimap.of();
}