For now I have this ugly code to check whether a hashmap contains null keys and values. Is there ready to use Guava static method with same functionality?
if (map != null) {
// Check map does not contains null key
try {
if (map.containsKey(null)) {
throw new IllegalArgumentException("map contains null as key");
}
} catch (NullPointerException e) {
//It is ok. Map does not permit null key.
}
// Check map does not contains null key
try {
if (map.containsValue(null)) {
throw new IllegalArgumentException("map contains null price");
}
} catch (NullPointerException e) {
//It is ok. Map does not permit null value.
}
}