本文整理了Java中com.google.common.collect.Multimap.containsKey()
方法的一些代码示例,展示了Multimap.containsKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multimap.containsKey()
方法的具体详情如下:
包路径:com.google.common.collect.Multimap
类名称:Multimap
方法名:containsKey
[英]Returns true if this multimap contains at least one key-value pair with the key key.
[中]如果此多重映射至少包含一个带有密钥的键值对,则返回true。
代码示例来源:origin: google/guava
@Override
public boolean containsKey(Object key) {
return fromMultimap.containsKey(key);
}
代码示例来源:origin: google/guava
@Override
public boolean containsKey(Object key) {
return multimap.containsKey(key);
}
代码示例来源:origin: google/guava
@Override
public boolean containsKey(Object key) {
synchronized (mutex) {
return delegate().containsKey(key);
}
}
代码示例来源:origin: google/guava
@Override
public boolean containsKey(@Nullable Object key) {
if (unfiltered.containsKey(key)) {
@SuppressWarnings("unchecked") // k is equal to a K, if not one itself
K k = (K) key;
return keyPredicate.apply(k);
}
return false;
}
代码示例来源:origin: google/guava
@Override
public boolean contains(@Nullable Object element) {
return multimap.containsKey(element);
}
代码示例来源:origin: google/guava
@Override
public boolean containsKey(@Nullable Object key) {
return delegate().containsKey(key);
}
代码示例来源:origin: google/guava
public void testContainsKeysFromKeySet() {
for (K k : multimap().keySet()) {
assertTrue(multimap().containsKey(k));
}
}
代码示例来源:origin: google/guava
public void testContainsKeyAgreesWithGet() {
for (K k : sampleKeys()) {
assertEquals(!multimap().get(k).isEmpty(), multimap().containsKey(k));
}
}
代码示例来源:origin: google/guava
public void testContainsKeyAgreesWithAsMap() {
for (K k : sampleKeys()) {
assertEquals(multimap().containsKey(k), multimap().asMap().containsKey(k));
}
}
代码示例来源:origin: google/guava
public void testContainsKeyAgreesWithKeySet() {
for (K k : sampleKeys()) {
assertEquals(multimap().containsKey(k), multimap().keySet().contains(k));
}
}
代码示例来源:origin: google/guava
@MapFeature.Require(absent = ALLOWS_NULL_KEY_QUERIES)
public void testContainsKeyNullDisallowed() {
try {
multimap().containsKey(null);
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
// success
}
}
}
代码示例来源:origin: google/guava
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testContainsKeyNullAbsent() {
assertFalse(multimap().containsKey(null));
}
代码示例来源:origin: google/guava
protected void assertGet(K key, Collection<V> values) {
assertEqualIgnoringOrder(values, multimap().get(key));
if (!values.isEmpty()) {
assertEqualIgnoringOrder(values, multimap().asMap().get(key));
assertFalse(multimap().isEmpty());
} else {
assertNull(multimap().asMap().get(key));
}
assertEquals(values.size(), multimap().get(key).size());
assertEquals(values.size() > 0, multimap().containsKey(key));
assertEquals(values.size() > 0, multimap().keySet().contains(key));
assertEquals(values.size() > 0, multimap().keys().contains(key));
}
代码示例来源:origin: google/guava
public void testContainsKeyNo() {
assertFalse(multimap().containsKey(k3()));
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
public void testContainsKeyYes() {
assertTrue(multimap().containsKey(k0()));
}
代码示例来源:origin: google/guava
@MapFeature.Require(ALLOWS_NULL_KEYS)
@CollectionSize.Require(absent = ZERO)
public void testContainsKeyNullPresent() {
initMultimapWithNullKey();
assertTrue(multimap().containsKey(null));
}
代码示例来源:origin: google/guava
@MapFeature.Require(SUPPORTS_PUT)
public void testPropagatesAddAllToMultimap() {
Collection<V> result = multimap().get(k0());
assertTrue(result.addAll(Collections.singletonList(v3())));
assertTrue(multimap().containsKey(k0()));
assertEquals(getNumElements() + 1, multimap().size());
assertTrue(multimap().containsEntry(k0(), v3()));
}
代码示例来源:origin: google/guava
@MapFeature.Require(SUPPORTS_PUT)
public void testPropagatesAddToMultimap() {
Collection<V> result = multimap().get(k0());
assertTrue(result.add(v3()));
assertTrue(multimap().containsKey(k0()));
assertEquals(getNumElements() + 1, multimap().size());
assertTrue(multimap().containsEntry(k0(), v3()));
}
代码示例来源:origin: google/guava
public void testMultimapReads() {
Multimap<String, Integer> multimap = createMultimap();
assertTrue(multimap.containsKey("foo"));
assertFalse(multimap.containsKey("cat"));
assertTrue(multimap.containsValue(1));
assertFalse(multimap.containsValue(5));
assertTrue(multimap.containsEntry("foo", 1));
assertFalse(multimap.containsEntry("cat", 1));
assertFalse(multimap.containsEntry("foo", 5));
assertFalse(multimap.entries().isEmpty());
assertEquals(3, multimap.size());
assertFalse(multimap.isEmpty());
assertEquals("{foo=[1, 3], bar=[2]}", multimap.toString());
}
代码示例来源:origin: google/guava
public void testMultimapReads() {
Multimap<String, Integer> multimap = createMultimap();
assertTrue(multimap.containsKey("foo"));
assertFalse(multimap.containsKey("cat"));
assertTrue(multimap.containsValue(1));
assertFalse(multimap.containsValue(5));
assertTrue(multimap.containsEntry("foo", 1));
assertFalse(multimap.containsEntry("cat", 1));
assertFalse(multimap.containsEntry("foo", 5));
assertFalse(multimap.entries().isEmpty());
assertEquals(3, multimap.size());
assertFalse(multimap.isEmpty());
assertEquals("{foo=[1, 3], bar=[2]}", multimap.toString());
}
内容来源于网络,如有侵权,请联系作者删除!