Package com.tangosol.util
Class RestrictedCollections.RestrictedMap
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.RestrictedCollections.RestrictedMap
- All Implemented Interfaces:
Serializable
,Map
- Direct Known Subclasses:
RestrictedCollections.RestrictedSortedMap
- Enclosing class:
RestrictedCollections
A restricted Map that requires its keys and values to be of
specified classes.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Check the passed object to verify that it passes the "key" restriction of this Map.protected void
checkValue
(Object o) Check the passed object to verify that it passes the "value" restriction of this Map.void
clear()
Removes all mappings from this map.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.entrySet()
Returns a set view of the mappings contained in this map.boolean
Compares the specified object with this map for equality.Returns the value to which this map maps the specified key.int
hashCode()
Returns the hash code value for this map.boolean
isEmpty()
Returns true if this map contains no key-value mappings.keySet()
Returns a set view of the keys contained in this map.Associates the specified value with the specified key in this map.void
Copies all of the mappings from the specified map to this map.Removes the mapping for this key from this map if present.int
size()
Returns the number of key-value mappings in this map.toString()
Return a String description for this Map.values()
Returns a collection view of the values contained in this map.Methods inherited from class com.tangosol.util.Base
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, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, 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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
m_map
The underlying Map. -
m_clzKey
The class of key stored in the Map. -
m_clzVal
The class of value stored in the Map. -
m_set
The Entry Set.
-
-
Constructor Details
-
RestrictedMap
Constructor.- Parameters:
map
- the underlying MapclzKey
- the class of keys that may be stored in the MapclzVal
- the class of values that may be stored in the Map
-
-
Method Details
-
size
public int size()Returns the number of key-value mappings in this map. -
isEmpty
public boolean isEmpty()Returns true if this map contains no key-value mappings. -
containsKey
Returns true if this map contains a mapping for the specified key.- Specified by:
containsKey
in interfaceMap
- Parameters:
key
- key whose presence in this map is to be tested- Returns:
- true if this map contains a mapping for the specified key
-
containsValue
Returns true if this map maps one or more keys to the specified value.- Specified by:
containsValue
in interfaceMap
- Parameters:
value
- value whose presence in this map is to be tested- Returns:
- true if this map maps one or more keys to the specified value.
-
get
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. -
put
Associates the specified value with the specified key in this map.- Specified by:
put
in interfaceMap
- Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key- Returns:
- previous value associated with specified key, or null if there was no mapping for key
- Throws:
ClassCastException
- if the class of the specified key or value prevents it from being stored in this map.
-
remove
Removes the mapping for this key from this map if present. -
putAll
Copies all of the mappings from the specified map to this map.- Specified by:
putAll
in interfaceMap
- Parameters:
map
- Mappings to be stored in this map- Throws:
ClassCastException
- if the class of a key or value in the specified map prevents it from being stored in this map
-
clear
public void clear()Removes all mappings from this map. -
keySet
Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. -
values
Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. -
entrySet
Returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. -
equals
Compares the specified object with this map for equality. Obeys the general contract of Map.equals. -
hashCode
public int hashCode()Returns the hash code value for this map. Obeys the general contract of Map.hashCode. -
toString
Return a String description for this Map. -
checkKey
Check the passed object to verify that it passes the "key" restriction of this Map.- Parameters:
o
- the Object to check- Throws:
ClassCastException
- if the class of the passed Object prevents it from being used as a key in this Map
-
checkValue
Check the passed object to verify that it passes the "value" restriction of this Map.- Parameters:
o
- the Object to check- Throws:
ClassCastException
- if the class of the passed Object prevents it from being used as a value in this Map
-