Package com.twelvemonkeys.util
Class AbstractDecoratedMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
com.twelvemonkeys.util.AbstractDecoratedMap<K,V>
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<K,
V>
- Direct Known Subclasses:
IgnoreCaseMap
,LinkedMap
,TimeoutMap
abstract class AbstractDecoratedMap<K,V>
extends AbstractMap<K,V>
implements Map<K,V>, Serializable, Cloneable
AbstractDecoratedMap
- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/util/AbstractDecoratedMap.java#2 $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
A simple Map.Entry implementation.protected class
protected class
protected class
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates aMap
backed by aHashMap
.AbstractDecoratedMap
(Map<? extends K, ? extends V> pContents) Creates aMap
backed by aHashMap
, containing all key/value mappings from the givenMap
.Creates aMap
backed by the given backing-Map
, containing all key/value mappings from the given contents-Map
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
protected Object
clone()
Returns a shallow copy of thisAbstractMap
instance: the keys and values themselves are not cloned.boolean
containsKey
(Object pKey) boolean
containsValue
(Object pValue) Returnstrue
if this map maps one or more keys to the specified pValue.createEntry
(K pKey, V pValue) entrySet()
abstract V
protected void
init()
Default implementation, does nothing.boolean
isEmpty()
keySet()
abstract V
abstract V
removeEntry
(Map.Entry<K, V> pEntry) Removes the given entry from the Map.int
size()
values()
Methods inherited from class java.util.AbstractMap
equals, hashCode, putAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
entries
-
modCount
protected transient volatile int modCount -
entrySet
-
keySet
-
values
-
-
Constructor Details
-
AbstractDecoratedMap
public AbstractDecoratedMap()Creates aMap
backed by aHashMap
. -
AbstractDecoratedMap
Creates aMap
backed by aHashMap
, containing all key/value mappings from the givenMap
.This is constructor is here to comply with the reccomendations for "standard" constructors in the
Map
interface.- Parameters:
pContents
- the map whose mappings are to be placed in this map. May benull
.- See Also:
-
AbstractDecoratedMap
Creates aMap
backed by the given backing-Map
, containing all key/value mappings from the given contents-Map
.NOTE: The backing map is structuraly cahnged, and it should NOT be accessed directly, after the wrapped map is created.
- Parameters:
pBacking
- the backing map of this map. Must be either empty, or the same map aspContents
.pContents
- the map whose mappings are to be placed in this map. May benull
.- Throws:
IllegalArgumentException
- ifpBacking
isnull
or ifpBacking
differs frompContent
and is not empty.
-
-
Method Details
-
init
protected void init()Default implementation, does nothing. -
size
public int size() -
clear
public void clear() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V> - Overrides:
containsKey
in classAbstractMap<K,
V>
-
containsValue
Returnstrue
if this map maps one or more keys to the specified pValue. More formally, returnstrue
if and only if this map contains at least one mapping to a pValuev
such that(pValue==null ? v==null : pValue.equals(v))
.This implementation requires time linear in the map size for this operation.
- Specified by:
containsValue
in interfaceMap<K,
V> - Overrides:
containsValue
in classAbstractMap<K,
V> - Parameters:
pValue
- pValue whose presence in this map is to be tested.- Returns:
true
if this map maps one or more keys to the specified pValue.
-
values
-
entrySet
-
keySet
-
clone
Returns a shallow copy of thisAbstractMap
instance: the keys and values themselves are not cloned.- Overrides:
clone
in classAbstractMap<K,
V> - Returns:
- a shallow copy of this map.
- Throws:
CloneNotSupportedException
-
newKeyIterator
-
newValueIterator
-
newEntryIterator
-
get
-
remove
-
put
-
createEntry
-
getEntry
-
removeEntry
Removes the given entry from the Map.- Parameters:
pEntry
- the entry to be removed- Returns:
- the removed entry, or
null
if nothing was removed.
-