| Modifier and Type | Method and Description |
|---|---|
static <K,V> Map<K,V> |
create() |
static <K,V> Map<K,V> |
empty() |
static <K,V> V |
get(Map<? super K,V> m,
K key)
This is a strongly-typed alternative to
Map.get(Object),
which restricts the type of the given key to a sub-type of
the declared key type of the map, and also specifies the
returned value can be null. |
static <K,V> Map<K,V> |
singleton(K k,
V v) |
public static <K,V> Map<K,V> empty()
public static <K,V> Map<K,V> singleton(K k, V v)
k - v - k to vpublic static <K,V> V get(Map<? super K,V> m, K key)
Map.get(Object),
which restricts the type of the given key to a sub-type of
the declared key type of the map, and also specifies the
returned value can be null. For some reason, the JDT
seemed to believe the result of Map.get(Object) was
non-null and this was leading to some bogus dead-code warnings.
NB: as of Aug. 5th, 2017, I have added external annotations
for some library classes such as Map, so that
Map.get(Object) now correctly returns a nullable value. This
wrapper remains of interest because of the stronger type constraint
on the key though.
m - key - key in m,
or null if there is no such elementpublic static <K,V> Map<K,V> create()