K - the key type of content of this MapV - the value type of content of this Mappublic abstract class ImmutableAbstractMap<K,V> extends Object implements ImmutableMap<K,V>
Copyright (c) 2016-2019 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
ImmutableMap.ImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
protected ImmutableCollection<V> |
cachedValues
the cached values.
|
protected Immutable |
copyOrWrap
COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection.
|
| Modifier | Constructor and Description |
|---|---|
protected |
ImmutableAbstractMap(Map<K,V> map,
Immutable copyOrWrap)
Construct an abstract immutable map.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified key.
|
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
|
boolean |
equals(Object obj)
Force to redefine equals for the implementations of immutable collection classes.
|
V |
get(Object key)
Returns the value to which the specified key is mapped, or
null if this map contains no mapping for the key. |
protected Map<K,V> |
getMap()
Prepare the map of the right type for use a subclass.
|
int |
hashCode()
Force to redefine hashCode for the implementations of immutable collection classes.
|
boolean |
isEmpty()
Returns true if this immutable collection contains no elements.
|
boolean |
isWrap()
Return whether the internal storage is a wrapped pointer to the original map.
|
int |
size()
Returns the number of elements in this immutable collection.
|
String |
toString() |
ImmutableCollection<V> |
values()
Returns a
ImmutableCollection view of the values contained in this map. |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitentrySet, forEach, getOrDefault, isCopy, keySet, toMapprotected final Immutable copyOrWrap
protected ImmutableCollection<V> cachedValues
protected ImmutableAbstractMap(Map<K,V> map, Immutable copyOrWrap)
map - Map<K,V>; a safe copy of the map to use for the immutable mapcopyOrWrap - Immutable; indicate whether the immutable is a copy or a wrapprotected Map<K,V> getMap()
@Override
protected HashMap<E> getMap()
{
return (HashMap<E>) super.getMap();
}
public final int size()
size in interface ImmutableMap<K,V>public final boolean isEmpty()
isEmpty in interface ImmutableMap<K,V>public final boolean containsKey(Object key)
containsKey in interface ImmutableMap<K,V>key - Object; key whose presence in this map is to be testedpublic final boolean containsValue(Object value)
containsValue in interface ImmutableMap<K,V>value - Object; value whose presence in this map is to be testedpublic final V get(Object key)
null if this map contains no mapping for the key.
More formally, if this map contains a mapping from a key k to a value v such that
(key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null.
(There can be at most one such mapping.)
If this map permits null values, then a return value of null does not necessarily indicate that the map
contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The
containsKey operation may be used to distinguish these two cases.
get in interface ImmutableMap<K,V>key - Object; the key whose associated value is to be returnednull if this map contains no mapping for the keypublic ImmutableCollection<V> values()
ImmutableCollection view of the values contained in this map.values in interface ImmutableMap<K,V>public final boolean isWrap()
isWrap in interface ImmutableMap<K,V>public int hashCode()
public boolean equals(Object obj)
Copyright © 2018–2019 Delft University of Technology. All rights reserved.