Udostępnij za pośrednictwem


Collections.CheckedNavigableMap(INavigableMap, Class, Class) Method

Definition

Returns a dynamically typesafe view of the specified navigable map.

[Android.Runtime.Register("checkedNavigableMap", "(Ljava/util/NavigableMap;Ljava/lang/Class;Ljava/lang/Class;)Ljava/util/NavigableMap;", "", ApiSince=26)]
[Java.Interop.JavaTypeParameters(new System.String[] { "K", "V" })]
public static Java.Util.INavigableMap CheckedNavigableMap (Java.Util.INavigableMap m, Java.Lang.Class keyType, Java.Lang.Class valueType);
[<Android.Runtime.Register("checkedNavigableMap", "(Ljava/util/NavigableMap;Ljava/lang/Class;Ljava/lang/Class;)Ljava/util/NavigableMap;", "", ApiSince=26)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "K", "V" })>]
static member CheckedNavigableMap : Java.Util.INavigableMap * Java.Lang.Class * Java.Lang.Class -> Java.Util.INavigableMap

Parameters

m
INavigableMap

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 navigable 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 <em>guaranteed</em> 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.8.

Java documentation for java.util.Collections.checkedNavigableMap(java.util.NavigableMap<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