K - The key classV - The value classpublic class KeyValueUtil<K,V> extends Object
Implementation note: This class could be using static methods. But it was decided to use Generics to spot errors in parameter passing more easily, e.g. mixing up key and value.
| Constructor and Description |
|---|
KeyValueUtil(String id)
Creates a typed KeyValueUtil for the given Cache.
|
| Modifier and Type | Method and Description |
|---|---|
void |
verifyKeyAndValueNotNull(K key,
V value)
Checks whether key or value are null.
|
void |
verifyKeyNotNull(K key)
Checks whether key is null.
|
void |
verifyKeysNotNull(Set<? extends K> keys) |
void |
verifyValueNotNull(V value)
Checks whether key is null.
|
public KeyValueUtil(String id)
id - The id (or cacheName) of the Cachepublic void verifyKeyAndValueNotNull(K key, V value)
JSR107 mandates to throw NullPointerException. This is not in the Javadoc of JSR107, but in the general part of the specification document: "Any attempt to use null for keys or values will result in a NullPointerException being thrown, regardless of the use."
key - The keyvalue - The valueNullPointerException - if at least one parameter is nullpublic void verifyKeyNotNull(K key)
JSR107 mandates to throw NullPointerException. This is not in the Javadoc of JSR107, but in the general part of the specification document: "Any attempt to use null for keys or values will result in a NullPointerException being thrown, regardless of the use."
key - The keyNullPointerException - if key is nullpublic void verifyValueNotNull(V value)
JSR107 mandates to throw NullPointerException. This is not in the Javadoc of JSR107, but in the general part of the specification document: "Any attempt to use null for keys or values will result in a NullPointerException being thrown, regardless of the use."
value - The valueNullPointerException - if value is nullCopyright © 2018 trivago. All rights reserved.