mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Make MultiMap use generics where sensible
I wonder why I orginally did not do it that way…
This commit is contained in:
parent
ce70308099
commit
e911874e72
1 changed files with 6 additions and 6 deletions
|
@ -77,11 +77,11 @@ public class MultiMap<K, V> {
|
||||||
return map.isEmpty();
|
return map.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsKey(Object key) {
|
public boolean containsKey(K key) {
|
||||||
return map.containsKey(key);
|
return map.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsValue(Object value) {
|
public boolean containsValue(V value) {
|
||||||
for (List<V> list : map.values()) {
|
for (List<V> list : map.values()) {
|
||||||
if (list.contains(value)) {
|
if (list.contains(value)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -96,7 +96,7 @@ public class MultiMap<K, V> {
|
||||||
* @param key
|
* @param key
|
||||||
* @return the first value or null.
|
* @return the first value or null.
|
||||||
*/
|
*/
|
||||||
public V getFirst(Object key) {
|
public V getFirst(K key) {
|
||||||
List<V> res = getAll(key);
|
List<V> res = getAll(key);
|
||||||
if (res.isEmpty()) {
|
if (res.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -114,7 +114,7 @@ public class MultiMap<K, V> {
|
||||||
* @param key
|
* @param key
|
||||||
* @return all values for the given key.
|
* @return all values for the given key.
|
||||||
*/
|
*/
|
||||||
public List<V> getAll(Object key) {
|
public List<V> getAll(K key) {
|
||||||
List<V> res = map.get(key);
|
List<V> res = map.get(key);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
res = Collections.emptyList();
|
res = Collections.emptyList();
|
||||||
|
@ -143,7 +143,7 @@ public class MultiMap<K, V> {
|
||||||
* @param key
|
* @param key
|
||||||
* @return the first value of the given key or null.
|
* @return the first value of the given key or null.
|
||||||
*/
|
*/
|
||||||
public V remove(Object key) {
|
public V remove(K key) {
|
||||||
List<V> res = map.remove(key);
|
List<V> res = map.remove(key);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -162,7 +162,7 @@ public class MultiMap<K, V> {
|
||||||
* @param value
|
* @param value
|
||||||
* @return true if the mapping was removed, false otherwise.
|
* @return true if the mapping was removed, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean removeOne(Object key, V value) {
|
public boolean removeOne(K key, V value) {
|
||||||
List<V> list = map.get(key);
|
List<V> list = map.get(key);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue