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
public static class RestrictedCollections.RestrictedMap extends Base implements Map, Serializable
A restricted Map that requires its keys and values to be of specified classes.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RestrictedMap(Map map, Class clzKey, Class clzVal)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkKey(Object o)
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.Set
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.Object
get(Object key)
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.Set
keySet()
Returns a set view of the keys contained in this map.Object
put(Object key, Object value)
Associates the specified value with the specified key in this map.void
putAll(Map map)
Copies all of the mappings from the specified map to this map.Object
remove(Object key)
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()
Return a String description for this Map.Collection
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
-
-
-
-
Method Detail
-
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
public boolean containsKey(Object key)
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
public boolean containsValue(Object value)
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
public Object get(Object key)
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key.
-
put
public Object put(Object key, Object value)
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.
-
putAll
public void putAll(Map map)
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
-
keySet
public Set 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
public Collection 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
public Set 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
public boolean equals(Object o)
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
public String toString()
Return a String description for this Map.
-
checkKey
protected void checkKey(Object o)
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
protected void checkValue(Object o)
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
-
-