From b4d13b1d89ac7bc5e9615258bf9963bb7d545620 Mon Sep 17 00:00:00 2001 From: Chrimle Date: Sun, 8 Dec 2024 23:21:36 +0100 Subject: [PATCH] Use Java Generics for `MultiKeyMap`-keys as method parameters --- .../commons/collections4/map/MultiKeyMap.java | 58 +++++++++---------- .../collections4/map/MultiKeyMapTest.java | 24 ++++---- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java b/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java index 71e468f6f..19cd48def 100644 --- a/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java +++ b/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java @@ -162,7 +162,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decoratedHashEntry(hashCode); while (entry != null) { @@ -182,7 +182,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decoratedHashEntry(hashCode); while (entry != null) { @@ -203,7 +203,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decoratedHashEntry(hashCode); while (entry != null) { @@ -225,7 +225,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decoratedHashEntry(hashCode); while (entry != null) { @@ -260,7 +260,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decoratedHashEntry(hashCode); while (entry != null) { @@ -280,7 +280,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decoratedHashEntry(hashCode); while (entry != null) { @@ -301,7 +301,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decoratedHashEntry(hashCode); while (entry != null) { @@ -323,7 +323,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decoratedHashEntry(hashCode); while (entry != null) { @@ -342,7 +342,7 @@ public class MultiKeyMap extends AbstractMapDecorator extends AbstractMapDecorator extends AbstractMapDecorator extends AbstractMapDecorator extends AbstractMapDecorator, V> entry, - final Object key1, final Object key2) { + final K key1, final K key2) { final MultiKey multi = entry.getKey(); return multi.size() == 2 && @@ -474,7 +474,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry, - final Object key1, final Object key2, final Object key3) { + final K key1, final K key2, final K key3) { final MultiKey multi = entry.getKey(); return multi.size() == 3 && @@ -494,7 +494,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry, - final Object key1, final Object key2, final Object key3, final Object key4) { + final K key1, final K key2, final K key3, final K key4) { final MultiKey multi = entry.getKey(); return multi.size() == 4 && @@ -516,7 +516,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry, - final Object key1, final Object key2, final Object key3, final Object key4, final Object key5) { + final K key1, final K key2, final K key3, final K key4, final K key5) { final MultiKey multi = entry.getKey(); return multi.size() == 5 && @@ -689,7 +689,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> it = mapIterator(); while (it.hasNext()) { @@ -714,7 +714,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> it = mapIterator(); while (it.hasNext()) { @@ -741,7 +741,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> it = mapIterator(); while (it.hasNext()) { @@ -770,7 +770,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> it = mapIterator(); while (it.hasNext()) { @@ -793,9 +793,9 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; @@ -819,9 +819,9 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; @@ -846,9 +846,9 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; @@ -874,10 +874,10 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; diff --git a/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java b/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java index 456269a27..34d9d0cd6 100644 --- a/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java @@ -172,19 +172,19 @@ public class MultiKeyMapTest extends AbstractIterableMapTest cloned = map.clone(); assertEquals(2, map.size()); - assertTrue(cloned.containsKey(I1, I3)); - assertTrue(cloned.containsKey(I1, I4)); - assertFalse(cloned.containsKey(I1, I2)); + assertTrue(cloned.containsKey((K) I1, (K) I3)); + assertTrue(cloned.containsKey((K) I1, (K) I4)); + assertFalse(cloned.containsKey((K) I1, (K) I2)); cloned.put((K) I1, (K) I5, (V) "1-5"); assertEquals(2, cloned.size()); - assertTrue(cloned.containsKey(I1, I4)); - assertTrue(cloned.containsKey(I1, I5)); + assertTrue(cloned.containsKey((K) I1, (K) I4)); + assertTrue(cloned.containsKey((K) I1, (K) I5)); } @Test @@ -428,7 +428,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest multimap = getMap(); assertEquals(12, multimap.size()); - multimap.removeAll(I1); + multimap.removeAll((K) I1); assertEquals(8, multimap.size()); for (final MapIterator, V> it = multimap.mapIterator(); it.hasNext();) { final MultiKey key = it.next(); @@ -442,7 +442,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest multimap = getMap(); assertEquals(12, multimap.size()); - multimap.removeAll(I2, I3); + multimap.removeAll((K) I2, (K) I3); assertEquals(9, multimap.size()); for (final MapIterator, V> it = multimap.mapIterator(); it.hasNext();) { final MultiKey key = it.next(); @@ -456,7 +456,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest multimap = getMap(); assertEquals(12, multimap.size()); - multimap.removeAll(I1, I1, I2); + multimap.removeAll((K) I1, (K) I1, (K) I2); assertEquals(9, multimap.size()); for (final MapIterator, V> it = multimap.mapIterator(); it.hasNext();) { final MultiKey key = it.next(); @@ -481,7 +481,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest multimap = getMap(); assertEquals(12, multimap.size()); - multimap.removeAll(I1, I1, I2, I3); + multimap.removeAll((K) I1, (K) I1, (K) I2, (K) I3); assertEquals(10, multimap.size()); for (final MapIterator, V> it = multimap.mapIterator(); it.hasNext();) { final MultiKey key = it.next();