public abstract class AbstractObject2ReferenceMap<K,V> extends AbstractObject2ReferenceFunction<K,V> implements Object2ReferenceMap<K,V>, Serializable
Optional operations just throw an UnsupportedOperationException.
Generic versions of accessors delegate to the corresponding type-specific
counterparts following the interface rules (they take care of returning
null on a missing key).
As a further help, this class provides a BasicEntry inner
class that implements a type-specific version of Map.Entry;
it is particularly useful for those classes that do not implement their own
entries (e.g., most immutable maps).
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractObject2ReferenceMap.BasicEntry<K,V>
This class provides a basic but complete type-specific entry class for
all those maps implementations that do not have entries on their own
(e.g., most immutable maps).
|
Object2ReferenceMap.Entry<K,V>, Object2ReferenceMap.FastEntrySet<K,V>| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(Object k)
Returns true if this function contains a mapping for the specified key.
|
boolean |
containsValue(Object v)
Returns true if this map maps one or more keys to the
specified value.
|
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one.
|
int |
hashCode()
Returns a hash code for this map.
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
ObjectSet<K> |
keySet()
Returns a type-specific-set view of the keys of this map.
|
void |
putAll(Map<? extends K,? extends V> m)
Copies all of the mappings from the specified map to this map
(optional operation).
|
String |
toString()
Returns a string representation of the object.
|
ReferenceCollection<V> |
values()
Returns a type-specific-set view of the values of this map.
|
defaultReturnValue, defaultReturnValueclear, defaultReturnValue, defaultReturnValue, entrySet, object2ReferenceEntrySet, put, remove, sizegetcompute, computeIfAbsent, computeIfPresent, forEach, get, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic boolean containsValue(Object v)
java.util.MapcontainsValue in interface Map<K,V>v - value whose presence in this map is to be testedpublic boolean containsKey(Object k)
Object2ReferenceMapcontainsKey in interface Object2ReferenceMap<K,V>containsKey in interface Map<K,V>k - the key.key.Map.containsKey(Object)public boolean isEmpty()
java.util.Mappublic ObjectSet<K> keySet()
The view is backed by the set returned by Map.entrySet(). Note
that no attempt is made at caching the result of this method, as
this would require adding some attributes that lightweight
implementations would not need. Subclasses may easily override this
policy by calling this method and caching the result, but implementors
are encouraged to write more efficient ad-hoc implementations.
keySet in interface Object2ReferenceMap<K,V>keySet in interface Map<K,V>Map.keySet()public ReferenceCollection<V> values()
The view is backed by the set returned by Map.entrySet(). Note
that no attempt is made at caching the result of this method, as
this would require adding some attributes that lightweight
implementations would not need. Subclasses may easily override this
policy by calling this method and caching the result, but implementors
are encouraged to write more efficient ad-hoc implementations.
values in interface Object2ReferenceMap<K,V>values in interface Map<K,V>Map.values()public void putAll(Map<? extends K,? extends V> m)
put(k, v) on this map once
for each mapping from key k to value v in the
specified map. The behavior of this operation is undefined if the
specified map is modified while the operation is in progress.public int hashCode()
hashCode in interface Map<K,V>hashCode in class ObjectObject.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)public boolean equals(Object o)
java.lang.Object
The equals method implements an equivalence relation
on non-null object references:
x, x.equals(x) should return
true.
x and y, x.equals(y)
should return true if and only if
y.equals(x) returns true.
x, y, and z, if
x.equals(y) returns true and
y.equals(z) returns true, then
x.equals(z) should return true.
x and y, multiple invocations of
x.equals(y) consistently return true
or consistently return false, provided no
information used in equals comparisons on the
objects is modified.
x,
x.equals(null) should return false.
The equals method for class Object implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x and
y, this method returns true if and only
if x and y refer to the same object
(x == y has the value true).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode method, which states
that equal objects must have equal hash codes.
public String toString()
java.lang.ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())