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) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Modifier | Constructor and Description |
---|---|
protected |
ImmutableAbstractMap(Map<K,V> map,
boolean copy)
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, wait
forEach, getOrDefault, isCopy, keySet, toMap
protected ImmutableAbstractMap(Map<K,V> map, boolean copy)
map
- a safe copy of the map to use as the immutable mapcopy
- 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
- key whose presence in this map is to be testedpublic final boolean containsValue(Object value)
containsValue
in interface ImmutableMap<K,V>
value
- 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
- the key whose associated value is to be returnednull
if this map contains no mapping for the keypublic final 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 © 2014–2016 Delft University of Technology. All rights reserved.