Aracılığıyla paylaş


Collections.CheckedMap(IDictionary, Class, Class) Method

Definition

Returns a dynamically typesafe view of the specified map.

[Android.Runtime.Register("checkedMap", "(Ljava/util/Map;Ljava/lang/Class;Ljava/lang/Class;)Ljava/util/Map;", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "K", "V" })]
public static System.Collections.IDictionary CheckedMap (System.Collections.IDictionary m, Java.Lang.Class keyType, Java.Lang.Class valueType);
[<Android.Runtime.Register("checkedMap", "(Ljava/util/Map;Ljava/lang/Class;Ljava/lang/Class;)Ljava/util/Map;", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "K", "V" })>]
static member CheckedMap : System.Collections.IDictionary * Java.Lang.Class * Java.Lang.Class -> System.Collections.IDictionary

Parameters

m
IDictionary

the map for which a dynamically typesafe view is to be returned

keyType
Class

the type of key that m is permitted to hold

valueType
Class

the type of value that m is permitted to hold

Returns

a dynamically typesafe view of the specified map

Attributes

Remarks

Returns a dynamically typesafe view of the specified map. Any attempt to insert a mapping whose key or value have the wrong type will result in an immediate ClassCastException. Similarly, any attempt to modify the value currently associated with a key will result in an immediate ClassCastException, whether the modification is attempted directly through the map itself, or through a Map.Entry instance obtained from the map's Map#entrySet() entry set view.

Assuming a map contains no incorrectly typed keys or values prior to the time a dynamically typesafe view is generated, and that all subsequent access to the map takes place through the view (or one of its collection views), it is guaranteed that the map cannot contain an incorrectly typed key or value.

A discussion of the use of dynamically typesafe views may be found in the documentation for the #checkedCollection checkedCollection method.

The returned map will be serializable if the specified map is serializable.

Since null is considered to be a value of any reference type, the returned map permits insertion of null keys or values whenever the backing map does.

Added in 1.5.

Java documentation for java.util.Collections.checkedMap(java.util.Map<K, V>, java.lang.Class<K>, java.lang.Class<V>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to