2494 |
|
} |
2495 |
|
|
2496 |
|
/** |
2497 |
+ |
* Returns the value to which the specified key is mapped, |
2498 |
+ |
* or the gieven defaultValue if this map contains no mapping for the key. |
2499 |
+ |
* |
2500 |
+ |
* @param key the key |
2501 |
+ |
* @param defaultValue the value to return if this map contains |
2502 |
+ |
* no mapping for the given key. |
2503 |
+ |
* @return the mapping for the key, if present; else the defaultValue |
2504 |
+ |
* @throws NullPointerException if the specified key is null |
2505 |
+ |
*/ |
2506 |
+ |
@SuppressWarnings("unchecked") public V getValueOrDefault(Object key, V defaultValue) { |
2507 |
+ |
if (key == null) |
2508 |
+ |
throw new NullPointerException(); |
2509 |
+ |
V v = (V) internalGet(key); |
2510 |
+ |
return v == null ? defaultValue : v; |
2511 |
+ |
} |
2512 |
+ |
|
2513 |
+ |
/** |
2514 |
|
* Tests if the specified object is a key in this table. |
2515 |
|
* |
2516 |
|
* @param key possible key |