Tabnine Logo
Map.replace
Code IndexAdd Tabnine to your IDE (free)

How to use
replace
method
in
java.util.Map

Best Java code snippets using java.util.Map.replace (Showing top 20 results out of 1,260)

origin: iluwatar/java-design-patterns

@Override
public boolean update(final Customer customer) {
 return idToCustomer.replace(customer.getId(), customer) != null;
}
origin: google/guava

@Override
public V replace(K key, V value) {
 synchronized (mutex) {
  return delegate().replace(key, value);
 }
}
origin: google/guava

@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUE_QUERIES)
public void testReplace_absentNullValueUnsupported() {
 try {
  getMap().replace(k3(), null);
 } catch (NullPointerException tolerated) {
  // permitted not to throw because it would be a no-op
 }
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_KEY_QUERIES)
public void testReplace_absentNullKeyUnsupported() {
 try {
  getMap().replace(null, v3());
 } catch (NullPointerException tolerated) {
  // permitted not to throw because it would be a no-op
 }
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUE_QUERIES})
public void testReplaceEntry_nullDifferentFromAbsent() {
 assertFalse(getMap().replace(k3(), null, v3()));
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUE_QUERIES)
public void testReplaceEntry_expectNullUnsupported() {
 try {
  assertFalse(getMap().replace(k3(), null, v3()));
 } catch (NullPointerException tolerated) {
  // the operation would be a no-op, so exceptions are allowed but not required
 }
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(SUPPORTS_PUT)
public void testReplace_supportedAbsent() {
 assertNull(getMap().replace(k3(), v3()));
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
public void testReplace_presentNullValueUnsupported() {
 try {
  getMap().replace(k0(), null);
  fail("Expected NullPointerException");
 } catch (NullPointerException expected) {
 }
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUE_QUERIES)
public void testReplaceEntry_absentKeyNullValueUnsupported() {
 try {
  assertFalse(getMap().replace(k3(), v3(), null));
 } catch (NullPointerException tolerated) {
  // the operation would be a no-op, so exceptions are allowed but not required
 }
 expectUnchanged();
}
origin: google/guava

 @MapFeature.Require(absent = SUPPORTS_PUT)
 public void testReplaceEntry_unsupportedAbsentKey() {
  try {
   getMap().replace(k3(), v3(), v4());
  } catch (UnsupportedOperationException tolerated) {
   // the operation would be a no-op, so exceptions are allowed but not required
  }
  expectUnchanged();
 }
}
origin: google/guava

@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUE_QUERIES)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_wrongValueNullValueUnsupported() {
 try {
  assertFalse(getMap().replace(k0(), v3(), null));
 } catch (NullPointerException tolerated) {
  // the operation would be a no-op, so exceptions are allowed but not required
 }
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(absent = SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_unsupportedWrongValue() {
 try {
  getMap().replace(k0(), v3(), v4());
 } catch (UnsupportedOperationException tolerated) {
  // the operation would be a no-op, so exceptions are allowed but not required
 }
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(SUPPORTS_PUT)
public void testReplaceEntry_supportedAbsentKey() {
 assertFalse(getMap().replace(k3(), v3(), v4()));
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_presentNullValueUnsupported() {
 try {
  getMap().replace(k0(), v0(), null);
  fail("Expected NullPointerException");
 } catch (NullPointerException expected) {
 }
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(absent = SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_unsupportedPresent() {
 try {
  getMap().replace(k0(), v0(), v3());
  fail("Expected UnsupportedOperationException");
 } catch (UnsupportedOperationException expected) {
 }
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresentUnchanged() {
 assertTrue(getMap().replace(k0(), v0(), v0()));
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplace_supportedPresentNoChange() {
 assertEquals(v0(), getMap().replace(k0(), v0()));
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedWrongValue() {
 assertFalse(getMap().replace(k0(), v3(), v4()));
 expectUnchanged();
}
origin: google/guava

@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplace_supportedPresent() {
 try {
  assertEquals(v0(), getMap().replace(k0(), v3()));
  expectReplacement(entry(k0(), v3()));
 } catch (ClassCastException tolerated) { // for ClassToInstanceMap
  expectUnchanged();
 }
}
origin: google/guava

@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresent() {
 try {
  assertTrue(getMap().replace(k0(), v0(), v3()));
  expectReplacement(entry(k0(), v3()));
 } catch (ClassCastException tolerated) { // for ClassToInstanceMap
  expectUnchanged();
 }
}
java.utilMapreplace

Popular methods of Map

  • put
    Maps the specified key to the specified value.
  • get
  • entrySet
    Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes t
  • containsKey
    Returns whether this Map contains the specified key.
  • keySet
    Returns a set of the keys contained in this Map. The Set is backed by this Map so changes to one are
  • values
    Returns a Collection view of the values contained in this map. The collection is backed by the map,
  • remove
  • size
    Returns the number of mappings in this Map.
  • isEmpty
    Returns true if this map contains no key-value mappings.
  • clear
    Removes all elements from this Map, leaving it empty.
  • putAll
    Copies all of the mappings from the specified map to this map (optional operation). The effect of th
  • forEach
  • putAll,
  • forEach,
  • equals,
  • computeIfAbsent,
  • hashCode,
  • getOrDefault,
  • containsValue,
  • putIfAbsent,
  • compute,
  • merge

Popular in Java

  • Making http requests using okhttp
  • getExternalFilesDir (Context)
  • runOnUiThread (Activity)
  • onRequestPermissionsResult (Fragment)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now