code: def replace_if_same(self, key, old_value, new_value):
          
          check_not_none(key, "key can't be None")
          check_not_none(old_value, "old_value can't be None")
          check_not_none(new_value, "new_value can't be None")
  
          key_data = self._to_data(key)
          old_value_data = self._to_data(old_value)
          new_value_data = self._to_data(new_value)
  
          return self._replace_if_same_internal(key_data, old_value_data, new_value_data)
docs: Replaces the entry for a key only if it is currently mapped to a given value.
  
          This is equivalent to:
              >>> if map.contains_key(key) and map.get(key).equals(old_value):
              >>>     map.put(key, new_value)
              >>>     return true
              >>> else:
              >>>     return false
          except that the action is performed atomically.
  
          **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations
          of __hash__ and __eq__ defined in key's class.**
  
          :param key: (object), the specified key.
          :param old_value: (object), replace the key value if it is the old value.
          :param new_value: (object), the new value to replace the old value.
          :return: (bool), ``true`` if the value was replaced.