本文整理匯總了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();
}