public abstract class AbstractKeyBasedMap<K,V> extends Base implements Map<K,V>
AbstractMap
abstract class and
this abstract class is this: that AbstractMap requires a sub-class to
provide an Entry Set implementation, while AbstractKeyBasedMap requires a
read-only sub-class to implement only get() and iterateKeys(), and a
read-write sub-class to additionally implement only put() and remove().
Read-only implementations must implement iterateKeys()
and
get(Object)
. Read/write implementations must additionally
implement put(Object, Object)
and remove(Object)
. A
number of the methods have implementations provided, but are extremely
inefficient for Maps that contain large amounts of data, including
clear()
, containsKey(Object)
, size()
(and by
extension isEmpty()
). Furthermore, if any of a number of method
implementations has any cost of returning an "old value", such as is done
by the put(K, V)
and remove(Object)
methods, then the
putAll(java.util.Map)
and removeBlind(Object)
methods should also be implemented.
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractKeyBasedMap.DeferredCacheEvent<K,V>
A DeferredCacheEvent is a
CacheEvent object that defers the loading
of the old value . |
class |
AbstractKeyBasedMap.EntrySet
A set of entries backed by this map.
|
protected class |
AbstractKeyBasedMap.KeySet
A set of keys backed by this map.
|
protected class |
AbstractKeyBasedMap.ValuesCollection
A Collection of values backed by this map.
|
Base.LoggingWriter, Base.StackFrame
Constructor and Description |
---|
AbstractKeyBasedMap() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all key/value mappings.
|
protected Object |
clone()
Returns a shallow copy of this AbstractKeyBasedMap instance;
the keySet, entrySet and values collections are not cloned or copied
to (shared by) the clone.
|
boolean |
containsKey(Object oKey)
Returns true if this map contains a mapping for the specified
key.
|
boolean |
containsValue(Object oValue)
Returns true if this Map maps one or more keys to the
specified value.
|
Set<Map.Entry<K,V>> |
entrySet()
Returns a set view of the mappings contained in this map.
|
boolean |
equals(Object o)
Compares the specified object with this map for equality.
|
abstract V |
get(Object oKey)
Returns the value to which this map maps the specified key.
|
Map<K,V> |
getAll(Collection<? extends K> colKeys)
Get all the specified keys, if they are in the Map.
|
int |
hashCode()
Returns the hash code value for this Map.
|
protected Set<Map.Entry<K,V>> |
instantiateEntrySet()
Factory pattern: Create a Set that represents the entries in the Map.
|
protected Set<K> |
instantiateKeySet()
Factory pattern: Create a Set that represents the keys in the Map
|
protected Collection<V> |
instantiateValues()
Factory pattern: Instantiate the values Collection.
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
protected abstract Iterator<K> |
iterateKeys()
Create an iterator over the keys in this Map.
|
Set<K> |
keySet()
Returns a set view of the keys contained in this map.
|
V |
put(K oKey,
V oValue)
Associates the specified value with the specified key in this map.
|
void |
putAll(Map<? extends K,? extends V> map)
Copies all of the mappings from the specified map to this map.
|
V |
remove(Object oKey)
Removes the mapping for this key from this map if present.
|
protected boolean |
removeBlind(Object oKey)
Removes the mapping for this key from this map if present.
|
int |
size()
Returns the number of key-value mappings in this map.
|
String |
toString()
Returns a string representation of this Map.
|
Collection<V> |
values()
Returns a collection view of the values contained in this map.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public boolean containsKey(Object oKey)
containsKey
in interface Map<K,V>
public boolean containsValue(Object oValue)
containsValue
in interface Map<K,V>
public Set<Map.Entry<K,V>> entrySet()
AbstractKeyBasedMap.EntrySet.Entry
. The set is backed by the
map, so changes to the map are reflected in the set, and vice-versa.
If the map is modified while an iteration over the set is in progress
(except by the iterator's own remove operation, or by the
setValue operation on a map entry returned by the iterator)
the results of the iteration are undefined. The set supports element
removal, which removes the corresponding mapping from the map, via the
Iterator.remove, Set.remove, removeAll,
retainAll and clear operations. It is not expected to
support the add or addAll operations.public boolean isEmpty()
public Set<K> keySet()
public V put(K oKey, V oValue)
public void putAll(Map<? extends K,? extends V> map)
put(K, V)
on this map once for each mapping in the passed map. The behavior of
this operation is unspecified if the passed map is modified while the
operation is in progress.public V remove(Object oKey)
remove
in interface Map<K,V>
oKey
- key whose mapping is to be removed from the mappublic int size()
public Collection<V> values()
public Map<K,V> getAll(Collection<? extends K> colKeys)
colKeys
- a collection of keys that may be in the named cacheprotected abstract Iterator<K> iterateKeys()
protected boolean removeBlind(Object oKey)
oKey
- key whose mapping is to be removed from the mappublic boolean equals(Object o)
public int hashCode()
public String toString()
protected Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
protected Set<K> instantiateKeySet()
protected Set<Map.Entry<K,V>> instantiateEntrySet()
protected Collection<V> instantiateValues()