下面列出了com.google.common.collect.SetMultimap#size ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void beforeNode(Object obj, DescriptorPath path) {
Preconditions.checkState(!refsStack.containsKey(path));
SetMultimap<ReferenceType, String> refs = getRelatedPaths(obj, path);
SetMultimap<ReferenceType, String> newRefs = LinkedHashMultimap.create();
for (Map.Entry<ReferenceType, Collection<String>> entry : refs.asMap().entrySet()) {
ReferenceType type = entry.getKey();
for (String reference : entry.getValue()) {
if (!allowedRefs.containsEntry(type, reference)) {
newRefs.put(type, reference);
allowedRefs.put(type, reference);
}
}
}
// consolidate into the singleton if it's empty
newRefs = newRefs.size() == 0 ? ImmutableSetMultimap
.<ReferenceType, String> of() : newRefs;
refsStack.put(path, newRefs);
callReferenceConstraints(obj, path);
}
@Override
public int size() {
final SetMultimap<K, V> setMultimap = get();
return (setMultimap == null) ? EMPTY_SETMULTIMAP.size()
: setMultimap.size();
}