com.hazelcast.core

## Interface BaseMap<K,V>

- Type Parameters:
    `K` - Key
    `V` - Value
  All Superinterfaces:
    DistributedObject
  All Known Subinterfaces:
    IMap<K,V>, IMapJet<K,V>, com.hazelcast.map.impl.LegacyAsyncMap<K,V>, TransactionalMap<K,V>
  All Known Implementing Classes:
    ClientMapProxy, ClientTxnMapProxy, NearCachedClientMapProxy

      public interface BaseMap<K,V>
      extends DistributedObject

  Base interface for Hazelcast distributed maps.
  See Also:
    `IMap`, `TransactionalMap`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsKey(Object key)` Returns `true` if this map contains an entry for the specified key.
    `void` | `delete(Object key)` Removes the mapping for a key from this map if it is present.
    `V` | `get(Object key)` Returns the value for the specified key, or `null` if this map does not contain this key.
    `boolean` | `isEmpty()` Returns `true` if this map contains no entries.
    `Set<K>` | `keySet()` Returns a set clone of the keys contained in this map.
    `Set<K>` | `keySet(Predicate predicate)` Queries the map based on the specified predicate and returns the keys of matching entries.
    `V` | `put(K key, V value)` Associates the specified value with the specified key in this map.
    `V` | `put(K key, V value, long ttl, TimeUnit timeunit)` Associates the specified value with the specified key in this map with a given ttl (time to live) value.
    `V` | `putIfAbsent(K key, V value)` If the specified key is not already associated with a value, associate it with the given value.
    `V` | `remove(Object key)` Removes the mapping for a key from this map if it is present.
    `boolean` | `remove(Object key, Object value)` Removes the entry for a key only if currently mapped to a given value.
    `V` | `replace(K key, V value)` Replaces the entry for a key only if it is currently mapped to some value.
    `boolean` | `replace(K key, V oldValue, V newValue)` Replaces the entry for a key only if currently mapped to a given value.
    `void` | `set(K key, V value)` Associates the specified value with the specified key in this map.
    `int` | `size()` Returns the number of entries in this map.
    `Collection<V>` | `values()` Returns a collection clone of the values contained in this map.
    `Collection<V>` | `values(Predicate predicate)` Queries the map based on the specified predicate and returns the values of matching entries.

    - ### Methods inherited from interface com.hazelcast.core.DistributedObject

      `destroy, getName, getPartitionKey, getServiceName`

- - ### Method Detail

    - #### containsKey

          boolean containsKey(Object key)

      Returns `true` if this map contains an entry for the specified key.
      Parameters:
        `key` - The specified key.
      Returns:
        `true` if this map contains an entry for the specified key.

    - #### get

          V get(Object key)

      Returns the value for the specified key, or `null` if this map does not contain this key.
      Parameters:
        `key` - The specified key.
      Returns:
        The value for the specified key.

    - #### put

          V put(K key,
                V value)

      Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value.
      Parameters:
        `key` - The specified key.
        `value` - The value to associate with the key.
      Returns:
        Previous value associated with `key` or `null` if there was no mapping for `key`.

    - #### put

          V put(K key,
                V value,
                long ttl,
                TimeUnit timeunit)

      Associates the specified value with the specified key in this map with a given ttl (time to live) value. Entry will expire and get evicted after the ttl. If ttl is 0, then the entry lives forever.
      Parameters:
        `key` - The specified key.
        `value` - The value to associate with the key.
        `ttl` - maximum time for this entry to stay in the map 0 means infinite.
        `timeunit` - time unit for the ttl
      Returns:
        Previous value associated with `key` or `null` if there was no mapping for `key`.

    - #### set

          void set(K key,
                   V value)

      Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value.

      This method is preferred to `put(Object, Object)` if the old value is not needed.
      Parameters:
        `key` - The specified key.
        `value` - The value to associate with the key.

    - #### putIfAbsent

          V putIfAbsent(K key,
                        V value)

      If the specified key is not already associated with a value, associate it with the given value. This is equivalent to

             if (!map.containsKey(key))
                 return map.put(key, value);
             else
                 return map.get(key);

      except that the action is performed atomically.
      Parameters:
        `key` - The specified key.
        `value` - The value to associate with the key when there is no previous value.
      Returns:
        The previous value associated with `key`, or `null` if there was no mapping for `key`.

    - #### replace

          V replace(K key,
                    V value)

      Replaces the entry for a key only if it is currently mapped to some value. This is equivalent to

             if (map.containsKey(key)) {
                 return map.put(key, value);
             } else return null;

      except that the action is performed atomically.
      Parameters:
        `key` - The specified key.
        `value` - The value to replace the previous value.
      Returns:
        The previous value associated with `key`, or `null` if there was no mapping for `key`.

    - #### replace

          boolean replace(K key,
                          V oldValue,
                          V newValue)

      Replaces the entry for a key only if currently mapped to a given value. This is equivalent to

             if (map.containsKey(key) && map.get(key).equals(oldValue)) {
                 map.put(key, newValue);
                 return true;
             } else return false;

      except that the action is performed atomically.
      Parameters:
        `key` - The specified key.
        `oldValue` - Replace the key value if it is the old value.
        `newValue` - The new value to replace the old value.
      Returns:
        `true` if the value was replaced.

    - #### remove

          V remove(Object key)

      Removes the mapping for a key from this map if it is present.

      The map will not contain a mapping for the specified key once the call returns.

      Parameters:
        `key` - Remove the mapping for this key.
      Returns:
        The previous value associated with `key`, or `null` if there was no mapping for `key`.

    - #### delete

          void delete(Object key)

      Removes the mapping for a key from this map if it is present.

      The map will not contain a mapping for the specified key once the call returns.

      *

      This method is preferred to `remove(Object)` if the old value is not needed.

      Parameters:
        `key` - Remove the mapping for this key.

    - #### remove

          boolean remove(Object key,
                         Object value)

      Removes the entry for a key only if currently mapped to a given value. This is equivalent to

             if (map.containsKey(key) && map.get(key).equals(value)) {
                 map.remove(key);
                 return true;
             } else return false;

      except that the action is performed atomically.
      Parameters:
        `key` - The specified key.
        `value` - Remove the key if it has this value.
      Returns:
        `true` if the value was removed.

    - #### isEmpty

          boolean isEmpty()

      Returns `true` if this map contains no entries.
      Returns:
        `true` if this map contains no entries.

    - #### size

          int size()

      Returns the number of entries in this map.
      Returns:
        the number of entries in this map.

    - #### keySet

          Set<K> keySet()

      Returns a set clone of the keys contained in this map.
      Returns:
        a set clone of the keys contained in this map.

    - #### keySet

          Set<K> keySet(Predicate predicate)

      Queries the map based on the specified predicate and returns the keys of matching entries.
      Parameters:
        `predicate` - specified query criteria.
      Returns:
        result key set of the query.
      Throws:
        `NullPointerException` - if the specified predicate is null.

    - #### values

          Collection<V> values()

      Returns a collection clone of the values contained in this map.
      Returns:
        a collection clone of the values contained in this map

    - #### values

          Collection<V> values(Predicate predicate)

      Queries the map based on the specified predicate and returns the values of matching entries.
      Parameters:
        `predicate` - specified query criteria.
      Returns:
        result value collection of the query.
      Throws:
        `NullPointerException` - if the predicate is null

Copyright © 2018. All rights reserved.