@Override public V forcePut(K key, V value) { synchronized (mutex) { return delegate().forcePut(key, value); } }
@Override public V forcePut(K key, V value) { synchronized (mutex) { return delegate().forcePut(key, value); } }
@Override public V forcePut(K key, V value) { assertTrue(Thread.holdsLock(mutex)); return delegate.forcePut(key, value); }
@Override public V forcePut(K key, V value) { synchronized (mutex) { return delegate().forcePut(key, value); } }
@Override public V forcePut(@NullableDecl K key, @NullableDecl V value) { checkArgument(apply(key, value)); return unfiltered().forcePut(key, value); }
@Override public V forcePut(@Nullable K key, @Nullable V value) { checkArgument(apply(key, value)); return unfiltered().forcePut(key, value); }
public void testForcePut() { create().forcePut(null, null); }
public void testInverseInsertionOrderAfterInverseForcePut() { BiMap<String, Integer> map = HashBiMap.create(); map.put("foo", 1); map.put("bar", 2); map.put("quux", 3); map.inverse().forcePut(1, "quux"); assertThat(map.inverse().entrySet()) .containsExactly(Maps.immutableEntry(2, "bar"), Maps.immutableEntry(1, "quux")) .inOrder(); }
public void testInsertionOrderAfterForcePut() { BiMap<String, Integer> map = HashBiMap.create(); map.put("foo", 1); map.put("bar", 2); map.put("quux", 3); map.forcePut("quux", 1); assertThat(map.entrySet()) .containsExactly(Maps.immutableEntry("bar", 2), Maps.immutableEntry("quux", 1)) .inOrder(); }
public void testInsertionOrderAfterInverseForcePut() { BiMap<String, Integer> map = HashBiMap.create(); map.put("foo", 1); map.put("bar", 2); map.put("quux", 3); map.inverse().forcePut(1, "quux"); assertThat(map.entrySet()) .containsExactly(Maps.immutableEntry("bar", 2), Maps.immutableEntry("quux", 1)) .inOrder(); }
public void testInverseInsertionOrderAfterInverseForcePutPresentKey() { BiMap<String, Integer> map = HashBiMap.create(); map.put("foo", 1); map.put("bar", 2); map.put("quux", 3); map.put("nab", 4); map.inverse().forcePut(4, "bar"); assertThat(map.entrySet()) .containsExactly( Maps.immutableEntry("foo", 1), Maps.immutableEntry("bar", 4), Maps.immutableEntry("quux", 3)) .inOrder(); }
public void testForcePut() { BiMap<String, Integer> bimap = ImmutableBiMap.copyOf(ImmutableMap.of("one", 1, "two", 2)); try { bimap.forcePut("three", 3); fail(); } catch (UnsupportedOperationException expected) { } }
void addResource(String type, String name, TypedResource value) { ResName resName = new ResName(packageName, type, name); // compound style names were previously registered with underscores (TextAppearance_Small) // because they came from R.style; re-register with dots. ResName resNameWithUnderscores = new ResName(packageName, type, underscorize(name)); Integer oldId = resourceTable.inverse().get(resNameWithUnderscores); if (oldId != null) { resourceTable.forcePut(oldId, resName); } Integer id = resourceTable.inverse().get(resName); if (id == null && isAndroidPackage(resName)) { id = androidResourceIdGenerator.generate(type, name); ResName existing = resourceTable.put(id, resName); if (existing != null) { throw new IllegalStateException(resName + " assigned ID to already existing " + existing); } } resources.put(resName, value); }
@Override public V forcePut(@NullableDecl K key, @NullableDecl V value) { checkArgument(apply(key, value)); return unfiltered().forcePut(key, value); }
@SuppressWarnings("unchecked") @MapFeature.Require(SUPPORTS_PUT) @CollectionSize.Require(ONE) public void testForcePutValuePresent() { getMap().forcePut(k1(), v0()); expectContents(Helpers.mapEntry(k1(), v0())); assertEquals(k1(), getMap().inverse().get(v0())); assertEquals(1, getMap().size()); assertFalse(getMap().containsKey(k0())); }
@SuppressWarnings("unchecked") @MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) @CollectionSize.Require(ONE) public void testForcePutNullValuePresent() { initMapWithNullValue(); getMap().forcePut(k1(), null); expectContents(Helpers.mapEntry(k1(), (V) null)); assertFalse(getMap().containsKey(k0())); assertTrue(getMap().containsKey(k1())); assertTrue(getMap().inverse().containsKey(null)); assertNull(getMap().get(k1())); assertEquals(k1(), getMap().inverse().get(null)); assertEquals(1, getMap().size()); }
@SuppressWarnings("unchecked") @MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_KEYS}) @CollectionSize.Require(ONE) public void testForcePutNullKeyPresent() { initMapWithNullKey(); getMap().forcePut(null, v1()); expectContents(Helpers.mapEntry((K) null, v1())); assertFalse(getMap().containsValue(v0())); assertTrue(getMap().containsValue(v1())); assertTrue(getMap().inverse().containsKey(v1())); assertNull(getMap().inverse().get(v1())); assertEquals(v1(), getMap().get(null)); assertEquals(1, getMap().size()); }
@SuppressWarnings("unchecked") @MapFeature.Require(SUPPORTS_PUT) @CollectionSize.Require(ONE) public void testForcePutKeyPresent() { getMap().forcePut(k0(), v1()); expectContents(Helpers.mapEntry(k0(), v1())); assertFalse(getMap().containsValue(v0())); assertNull(getMap().inverse().get(v0())); assertEquals(1, getMap().size()); assertTrue(getMap().containsKey(k0())); }
@SuppressWarnings("unchecked") @MapFeature.Require(SUPPORTS_PUT) @CollectionSize.Require(SEVERAL) public void testForcePutKeyAndValuePresent() { getMap().forcePut(k0(), v1()); expectContents(Helpers.mapEntry(k0(), v1()), Helpers.mapEntry(k2(), v2())); assertEquals(2, getMap().size()); assertFalse(getMap().containsKey(k1())); assertFalse(getMap().containsValue(v0())); }