本文整理匯總了Java中com.google.common.collect.ListMultimap.removeAll方法的典型用法代碼示例。如果您正苦於以下問題:Java ListMultimap.removeAll方法的具體用法?Java ListMultimap.removeAll怎麽用?Java ListMultimap.removeAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.ListMultimap
的用法示例。
在下文中一共展示了ListMultimap.removeAll方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: remove
import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
DOMRpcRoutingTable remove(final DOMRpcImplementation implementation, final Set<DOMRpcIdentifier> rpcs) {
if (rpcs.isEmpty()) {
return this;
}
// First decompose the identifiers to a multimap
final ListMultimap<SchemaPath, YangInstanceIdentifier> toRemove = decomposeIdentifiers(rpcs);
// Now iterate over existing entries, modifying them as appropriate...
final Builder<SchemaPath, AbstractDOMRpcRoutingTableEntry> b = ImmutableMap.builder();
for (Entry<SchemaPath, AbstractDOMRpcRoutingTableEntry> e : this.rpcs.entrySet()) {
final List<YangInstanceIdentifier> removed = new ArrayList<>(toRemove.removeAll(e.getKey()));
if (!removed.isEmpty()) {
final AbstractDOMRpcRoutingTableEntry ne = e.getValue().remove(implementation, removed);
if (ne != null) {
b.put(e.getKey(), ne);
}
} else {
b.put(e);
}
}
// All done, whatever is in toRemove, was not there in the first place
return new DOMRpcRoutingTable(b.build(), schemaContext);
}
示例2: add
import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
DOMRpcRoutingTable add(final DOMRpcImplementation implementation, final Set<DOMRpcIdentifier> rpcs) {
if (rpcs.isEmpty()) {
return this;
}
// First decompose the identifiers to a multimap
final ListMultimap<SchemaPath, YangInstanceIdentifier> toAdd = decomposeIdentifiers(rpcs);
// Now iterate over existing entries, modifying them as appropriate...
final Builder<SchemaPath, AbstractDOMRpcRoutingTableEntry> mb = ImmutableMap.builder();
for (Entry<SchemaPath, AbstractDOMRpcRoutingTableEntry> re : this.rpcs.entrySet()) {
List<YangInstanceIdentifier> newRpcs = new ArrayList<>(toAdd.removeAll(re.getKey()));
if (!newRpcs.isEmpty()) {
final AbstractDOMRpcRoutingTableEntry ne = re.getValue().add(implementation, newRpcs);
mb.put(re.getKey(), ne);
} else {
mb.put(re);
}
}
// Finally add whatever is left in the decomposed multimap
for (Entry<SchemaPath, Collection<YangInstanceIdentifier>> e : toAdd.asMap().entrySet()) {
final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
final List<DOMRpcImplementation> v = Collections.singletonList(implementation);
for (YangInstanceIdentifier i : e.getValue()) {
vb.put(i, v);
}
mb.put(e.getKey(), createRpcEntry(schemaContext, e.getKey(), vb.build()));
}
return new DOMRpcRoutingTable(mb.build(), schemaContext);
}