Fix up generics and other warnings
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@966367 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3d86019dad
commit
fb3daab4fd
|
@ -415,7 +415,7 @@ class BulkTestSuiteMaker {
|
|||
private static <T extends BulkTest> BulkTest makeTestCase(Class<T> c, Method m) {
|
||||
Constructor<T> con = getTestCaseConstructor(c);
|
||||
try {
|
||||
return (BulkTest) con.newInstance(new Object[] { m.getName() });
|
||||
return con.newInstance(new Object[] { m.getName() });
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(); // FIXME;
|
||||
|
|
|
@ -73,7 +73,7 @@ class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements
|
|||
/**
|
||||
* Method compareTo
|
||||
*
|
||||
* @param o
|
||||
* @param other
|
||||
*
|
||||
* @return a negative integer, zero, or a positive integer
|
||||
* as this object is less than, equal to, or greater than the specified object.
|
||||
|
@ -97,7 +97,6 @@ class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements
|
|||
* @return true if equal
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o == null) {
|
||||
|
|
|
@ -115,8 +115,8 @@ public class TestListUtils extends BulkTest {
|
|||
* Tests intersecting two lists in different orders.
|
||||
*/
|
||||
public void testIntersectionOrderInsensitivity() {
|
||||
List one = new ArrayList();
|
||||
List two = new ArrayList();
|
||||
List<String> one = new ArrayList<String>();
|
||||
List<String> two = new ArrayList<String>();
|
||||
one.add("a");
|
||||
one.add("b");
|
||||
two.add("a");
|
||||
|
@ -237,7 +237,7 @@ public class TestListUtils extends BulkTest {
|
|||
*/
|
||||
// TODO: Generics
|
||||
public void testIndexOf() {
|
||||
Predicate testPredicate = PredicateUtils.equalPredicate("d");
|
||||
Predicate<String> testPredicate = PredicateUtils.equalPredicate("d");
|
||||
int index = ListUtils.indexOf(fullList, testPredicate);
|
||||
assertEquals(d, fullList.get(index));
|
||||
|
||||
|
|
|
@ -374,7 +374,7 @@ public abstract class AbstractTestBag<T> extends AbstractTestObject {
|
|||
bag.add((T) "B");
|
||||
bag.add((T) "B");
|
||||
bag.add((T) "C");
|
||||
String[] array = (String[]) bag.toArray(new String[0]);
|
||||
String[] array = bag.toArray(new String[0]);
|
||||
int a = 0, b = 0, c = 0;
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
a += (array[i].equals("A") ? 1 : 0);
|
||||
|
@ -455,13 +455,12 @@ public abstract class AbstractTestBag<T> extends AbstractTestObject {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testEmptyBagSerialization() throws IOException, ClassNotFoundException {
|
||||
Bag<T> bag = makeObject();
|
||||
if (!(bag instanceof Serializable && isTestSerialization())) return;
|
||||
|
||||
byte[] objekt = writeExternalFormToBytes((Serializable) bag);
|
||||
Bag bag2 = (Bag) readExternalFormFromBytes(objekt);
|
||||
Bag<?> bag2 = (Bag<?>) readExternalFormFromBytes(objekt);
|
||||
|
||||
assertEquals("Bag should be empty",0, bag.size());
|
||||
assertEquals("Bag should be empty",0, bag2.size());
|
||||
|
@ -479,7 +478,7 @@ public abstract class AbstractTestBag<T> extends AbstractTestObject {
|
|||
if (!(bag instanceof Serializable && isTestSerialization())) return;
|
||||
|
||||
byte[] objekt = writeExternalFormToBytes((Serializable) bag);
|
||||
Bag bag2 = (Bag) readExternalFormFromBytes(objekt);
|
||||
Bag<?> bag2 = (Bag<?>) readExternalFormFromBytes(objekt);
|
||||
|
||||
assertEquals("Bag should be same size", size, bag.size());
|
||||
assertEquals("Bag should be same size", size, bag2.size());
|
||||
|
@ -501,12 +500,11 @@ public abstract class AbstractTestBag<T> extends AbstractTestObject {
|
|||
* Compare the current serialized form of the Bag
|
||||
* against the canonical version in SVN.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testEmptyBagCompatibility() throws IOException, ClassNotFoundException {
|
||||
// test to make sure the canonical form has been preserved
|
||||
Bag<T> bag = makeObject();
|
||||
if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
|
||||
Bag bag2 = (Bag) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag));
|
||||
Bag<?> bag2 = (Bag<?>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag));
|
||||
assertTrue("Bag is empty",bag2.size() == 0);
|
||||
assertEquals(bag, bag2);
|
||||
}
|
||||
|
|
|
@ -70,12 +70,12 @@ public class TestTransformedSortedBag<T> extends AbstractTestSortedBag<T> {
|
|||
}
|
||||
|
||||
public void testTransformedBag_decorateTransform() {
|
||||
Bag originalBag = new TreeBag();
|
||||
Bag<Object> originalBag = new TreeBag<Object>();
|
||||
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
|
||||
for (int i = 0; i < els.length; i++) {
|
||||
originalBag.add(els[i]);
|
||||
}
|
||||
Bag bag = TransformedBag.decorateTransform(originalBag, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
|
||||
Bag<?> bag = TransformedBag.decorateTransform(originalBag, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
|
||||
assertEquals(els.length, bag.size());
|
||||
for (int i = 0; i < els.length; i++) {
|
||||
assertEquals(true, bag.contains(new Integer((String) els[i])));
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.commons.collections.bidimap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -77,9 +76,8 @@ public class TestDualTreeBidiMap2<K extends Comparable<K>, V extends Comparable<
|
|||
assertTrue(bidi.comparator() instanceof ReverseComparator);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSerializeDeserializeCheckComparator() throws Exception {
|
||||
SortedBidiMap obj = (SortedBidiMap) makeObject();
|
||||
SortedBidiMap<?, ?> obj = makeObject();
|
||||
if (obj instanceof Serializable && isTestSerialization()) {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(buffer);
|
||||
|
|
|
@ -283,8 +283,8 @@ public abstract class AbstractTestList<E> extends AbstractTestCollection<E> {
|
|||
|
||||
for (int i = 0; i <= max; i++) {
|
||||
resetFull();
|
||||
((List<E>) getCollection()).add(i, element);
|
||||
((List<E>) getConfirmed()).add(i, element);
|
||||
getCollection().add(i, element);
|
||||
getConfirmed().add(i, element);
|
||||
verify();
|
||||
}
|
||||
}
|
||||
|
@ -621,9 +621,9 @@ public abstract class AbstractTestList<E> extends AbstractTestCollection<E> {
|
|||
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
E n = other[i % other.length];
|
||||
E v = ((List<E>) getCollection()).set(i, n);
|
||||
E v = (getCollection()).set(i, n);
|
||||
assertEquals("Set should return correct element", elements[i], v);
|
||||
((List<E>) getConfirmed()).set(i, n);
|
||||
(getConfirmed()).set(i, n);
|
||||
verify();
|
||||
}
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ public abstract class AbstractTestList<E> extends AbstractTestCollection<E> {
|
|||
|
||||
resetFull();
|
||||
try {
|
||||
((List<E>) getCollection()).set(0, getFullElements()[0]);
|
||||
(getCollection()).set(0, getFullElements()[0]);
|
||||
fail("Emtpy collection should not support set.");
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// expected
|
||||
|
@ -742,8 +742,8 @@ public abstract class AbstractTestList<E> extends AbstractTestCollection<E> {
|
|||
int max = getFullElements().length;
|
||||
for (int i = 0; i < max; i++) {
|
||||
resetFull();
|
||||
E o1 = ((List<E>) getCollection()).remove(i);
|
||||
E o2 = ((List<E>) getConfirmed()).remove(i);
|
||||
E o1 = (getCollection()).remove(i);
|
||||
E o2 = (getConfirmed()).remove(i);
|
||||
assertEquals("remove should return correct element", o1, o2);
|
||||
verify();
|
||||
}
|
||||
|
|
|
@ -745,7 +745,6 @@ public abstract class AbstractTestMap<K, V> extends AbstractTestObject {
|
|||
* Compare the current serialized form of the Map
|
||||
* against the canonical version in SVN.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testEmptyMapCompatibility() throws Exception {
|
||||
/**
|
||||
* Create canonical objects with this code
|
||||
|
@ -756,9 +755,10 @@ public abstract class AbstractTestMap<K, V> extends AbstractTestObject {
|
|||
*/
|
||||
|
||||
// test to make sure the canonical form has been preserved
|
||||
Map map = makeObject();
|
||||
Map<K, V> map = makeObject();
|
||||
if (map instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
|
||||
Map map2 = (Map) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map));
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<K, V> map2 = (Map<K, V>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map));
|
||||
assertEquals("Map is empty", 0, map2.size());
|
||||
}
|
||||
}
|
||||
|
@ -767,7 +767,6 @@ public abstract class AbstractTestMap<K, V> extends AbstractTestObject {
|
|||
* Compare the current serialized form of the Map
|
||||
* against the canonical version in SVN.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testFullMapCompatibility() throws Exception {
|
||||
/**
|
||||
* Create canonical objects with this code
|
||||
|
@ -778,9 +777,10 @@ public abstract class AbstractTestMap<K, V> extends AbstractTestObject {
|
|||
*/
|
||||
|
||||
// test to make sure the canonical form has been preserved
|
||||
Map map = makeFullMap();
|
||||
Map<K, V> map = makeFullMap();
|
||||
if (map instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
|
||||
Map map2 = (Map) readExternalFormFromDisk(getCanonicalFullCollectionName(map));
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<K, V> map2 = (Map<K, V>) readExternalFormFromDisk(getCanonicalFullCollectionName(map));
|
||||
assertEquals("Map is the right size", getSampleKeys().length, map2.size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ public class TestCaseInsensitiveMap<K, V> extends AbstractTestIterableMap<K, V>
|
|||
Locale.setDefault(locales[i]);
|
||||
for (int j = 0; j < data.length; j++) {
|
||||
assertTrue("Test data corrupt: " + j, data[j][0].equalsIgnoreCase(data[j][1]));
|
||||
CaseInsensitiveMap map = new CaseInsensitiveMap();
|
||||
CaseInsensitiveMap<String, String> map = new CaseInsensitiveMap<String, String>();
|
||||
map.put(data[j][0], "value");
|
||||
assertEquals(Locale.getDefault() + ": " + j, "value", map.get(data[j][1]));
|
||||
}
|
||||
|
|
|
@ -154,7 +154,6 @@ public class TestFlat3Map<K, V> extends AbstractTestIterableMap<K, V> {
|
|||
assertSame(TWO, cloned.get(TWENTY));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSerialisation0() throws Exception {
|
||||
Flat3Map<K, V> map = makeObject();
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
|
@ -164,7 +163,7 @@ public class TestFlat3Map<K, V> extends AbstractTestIterableMap<K, V> {
|
|||
out.close();
|
||||
ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
|
||||
ObjectInputStream in = new ObjectInputStream(bin);
|
||||
Flat3Map ser = (Flat3Map) in.readObject();
|
||||
Flat3Map<?, ?> ser = (Flat3Map<?, ?>) in.readObject();
|
||||
in.close();
|
||||
assertEquals(0, map.size());
|
||||
assertEquals(0, ser.size());
|
||||
|
@ -183,7 +182,7 @@ public class TestFlat3Map<K, V> extends AbstractTestIterableMap<K, V> {
|
|||
out.close();
|
||||
ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
|
||||
ObjectInputStream in = new ObjectInputStream(bin);
|
||||
Flat3Map ser = (Flat3Map) in.readObject();
|
||||
Flat3Map<?, ?> ser = (Flat3Map<?, ?>) in.readObject();
|
||||
in.close();
|
||||
assertEquals(2, map.size());
|
||||
assertEquals(2, ser.size());
|
||||
|
@ -208,7 +207,7 @@ public class TestFlat3Map<K, V> extends AbstractTestIterableMap<K, V> {
|
|||
out.close();
|
||||
ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
|
||||
ObjectInputStream in = new ObjectInputStream(bin);
|
||||
Flat3Map ser = (Flat3Map) in.readObject();
|
||||
Flat3Map<?, ?> ser = (Flat3Map<?, ?>) in.readObject();
|
||||
in.close();
|
||||
assertEquals(4, map.size());
|
||||
assertEquals(4, ser.size());
|
||||
|
@ -418,7 +417,7 @@ public class TestFlat3Map<K, V> extends AbstractTestIterableMap<K, V> {
|
|||
// }
|
||||
|
||||
public void testCollections261() {
|
||||
Flat3Map m = new Flat3Map();
|
||||
Flat3Map<Integer, Integer> m = new Flat3Map<Integer, Integer>();
|
||||
m.put( new Integer(1), new Integer(1) );
|
||||
m.put( new Integer(0), new Integer(0) );
|
||||
assertEquals( new Integer(1), m.remove( new Integer(1) ) );
|
||||
|
|
|
@ -121,12 +121,12 @@ public class TestIdentityMap<K, V> extends AbstractTestObject {
|
|||
* Compare the current serialized form of the Map
|
||||
* against the canonical version in SVN.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testEmptyMapCompatibility() throws IOException, ClassNotFoundException {
|
||||
// test to make sure the canonical form has been preserved
|
||||
Map<K, V> map = makeObject();
|
||||
if (map instanceof Serializable && !skipSerializedCanonicalTests()) {
|
||||
Map map2 = (Map) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map));
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<K, V> map2 = (Map<K, V>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map));
|
||||
assertEquals("Map is empty", 0, map2.size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testRemoveLRU() {
|
||||
MockLRUMapSubclass map = new MockLRUMapSubclass(2);
|
||||
MockLRUMapSubclass<K, String> map = new MockLRUMapSubclass<K, String>(2);
|
||||
assertNull(map.entry);
|
||||
map.put((K) "A", "a");
|
||||
assertNull(map.entry);
|
||||
|
@ -484,9 +484,9 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
|
|||
// TODO: COLLECTIONS-330
|
||||
public void todoTestSynchronizedRemoveFromMapIterator() throws InterruptedException {
|
||||
|
||||
final LRUMap map = new LRUMap(10000);
|
||||
final LRUMap<Object, Thread> map = new LRUMap<Object, Thread>(10000);
|
||||
|
||||
final Map exceptions = new HashMap();
|
||||
final Map<Throwable, String> exceptions = new HashMap<Throwable, String>();
|
||||
final ThreadGroup tg = new ThreadGroup(getName()) {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
|
@ -516,7 +516,7 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
|
|||
}
|
||||
}
|
||||
synchronized (map) {
|
||||
for (MapIterator iter = map.mapIterator(); iter.hasNext();) {
|
||||
for (MapIterator<Object, Thread> iter = map.mapIterator(); iter.hasNext();) {
|
||||
String name = (String)iter.next();
|
||||
if (map.get(name) == this) {
|
||||
iter.remove();
|
||||
|
@ -567,9 +567,9 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
|
|||
|
||||
public void testSynchronizedRemoveFromEntrySet() throws InterruptedException {
|
||||
|
||||
final Map map = new LRUMap(10000);
|
||||
final Map<Object, Thread> map = new LRUMap<Object, Thread>(10000);
|
||||
|
||||
final Map exceptions = new HashMap();
|
||||
final Map<Throwable, String> exceptions = new HashMap<Throwable, String>();
|
||||
final ThreadGroup tg = new ThreadGroup(getName()) {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
|
@ -599,8 +599,8 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
|
|||
}
|
||||
}
|
||||
synchronized (map) {
|
||||
for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
for (Iterator<Map.Entry<Object, Thread>> iter = map.entrySet().iterator(); iter.hasNext();) {
|
||||
Map.Entry<Object, Thread> entry = iter.next();
|
||||
if (entry.getValue() == this) {
|
||||
iter.remove();
|
||||
}
|
||||
|
@ -651,9 +651,9 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
|
|||
// TODO: COLLECTIONS-330
|
||||
public void todoTestSynchronizedRemoveFromKeySet() throws InterruptedException {
|
||||
|
||||
final Map map = new LRUMap(10000);
|
||||
final Map<Object, Thread> map = new LRUMap<Object, Thread>(10000);
|
||||
|
||||
final Map exceptions = new HashMap();
|
||||
final Map<Throwable, String> exceptions = new HashMap<Throwable, String>();
|
||||
final ThreadGroup tg = new ThreadGroup(getName()) {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
|
@ -683,7 +683,7 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
|
|||
}
|
||||
}
|
||||
synchronized (map) {
|
||||
for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
|
||||
for (Iterator<Object> iter = map.keySet().iterator(); iter.hasNext();) {
|
||||
String name = (String)iter.next();
|
||||
if (map.get(name) == this) {
|
||||
iter.remove();
|
||||
|
@ -734,9 +734,9 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
|
|||
|
||||
public void testSynchronizedRemoveFromValues() throws InterruptedException {
|
||||
|
||||
final Map map = new LRUMap(10000);
|
||||
final Map<Object, Thread> map = new LRUMap<Object, Thread>(10000);
|
||||
|
||||
final Map exceptions = new HashMap();
|
||||
final Map<Throwable, String> exceptions = new HashMap<Throwable, String>();
|
||||
final ThreadGroup tg = new ThreadGroup(getName()) {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
|
@ -766,7 +766,7 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
|
|||
}
|
||||
}
|
||||
synchronized (map) {
|
||||
for (Iterator iter = map.values().iterator(); iter.hasNext();) {
|
||||
for (Iterator<Thread> iter = map.values().iterator(); iter.hasNext();) {
|
||||
if (iter.next() == this) {
|
||||
iter.remove();
|
||||
}
|
||||
|
|
|
@ -68,18 +68,18 @@ public class TestMultiKeyMap<K, V> extends AbstractTestIterableMap<MultiKey<? ex
|
|||
@SuppressWarnings("unchecked")
|
||||
private MultiKey<K>[] getMultiKeyKeys() {
|
||||
return new MultiKey[] {
|
||||
new MultiKey(I1, I2),
|
||||
new MultiKey(I2, I3),
|
||||
new MultiKey(I3, I4),
|
||||
new MultiKey(I1, I1, I2),
|
||||
new MultiKey(I2, I3, I4),
|
||||
new MultiKey(I3, I7, I6),
|
||||
new MultiKey(I1, I1, I2, I3),
|
||||
new MultiKey(I2, I4, I5, I6),
|
||||
new MultiKey(I3, I6, I7, I8),
|
||||
new MultiKey(I1, I1, I2, I3, I4),
|
||||
new MultiKey(I2, I3, I4, I5, I6),
|
||||
new MultiKey(I3, I5, I6, I7, I8),
|
||||
new MultiKey<Integer>(I1, I2),
|
||||
new MultiKey<Integer>(I2, I3),
|
||||
new MultiKey<Integer>(I3, I4),
|
||||
new MultiKey<Integer>(I1, I1, I2),
|
||||
new MultiKey<Integer>(I2, I3, I4),
|
||||
new MultiKey<Integer>(I3, I7, I6),
|
||||
new MultiKey<Integer>(I1, I1, I2, I3),
|
||||
new MultiKey<Integer>(I2, I4, I5, I6),
|
||||
new MultiKey<Integer>(I3, I6, I7, I8),
|
||||
new MultiKey<Integer>(I1, I1, I2, I3, I4),
|
||||
new MultiKey<Integer>(I2, I3, I4, I5, I6),
|
||||
new MultiKey<Integer>(I3, I5, I6, I7, I8),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -108,11 +108,11 @@ public class TestMultiKeyMap<K, V> extends AbstractTestIterableMap<MultiKey<? ex
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public MultiKey<K>[] getOtherKeys() {
|
||||
return (MultiKey<K>[]) new MultiKey[] {
|
||||
new MultiKey(I1, I7),
|
||||
new MultiKey(I1, I8),
|
||||
new MultiKey(I2, I4),
|
||||
new MultiKey(I2, I5),
|
||||
return new MultiKey[] {
|
||||
new MultiKey<Integer>(I1, I7),
|
||||
new MultiKey<Integer>(I1, I8),
|
||||
new MultiKey<Integer>(I2, I4),
|
||||
new MultiKey<Integer>(I2, I5),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public class TestTransformedMap<K, V> extends AbstractTestIterableMap<K, V> {
|
|||
assertEquals(new Integer(66), array[0].getValue());
|
||||
assertEquals(new Integer(66), map.get(array[0].getKey()));
|
||||
|
||||
Map.Entry entry = (Map.Entry) entrySet.iterator().next();
|
||||
Map.Entry entry = entrySet.iterator().next();
|
||||
entry.setValue("88");
|
||||
assertEquals(new Integer(88), entry.getValue());
|
||||
assertEquals(new Integer(88), map.get(entry.getKey()));
|
||||
|
|
|
@ -114,7 +114,7 @@ public class TestTransformedSortedMap<K, V> extends AbstractTestSortedMap<K, V>
|
|||
assertEquals(new Integer((String) els[0]), map.remove(els[0]));
|
||||
|
||||
Set<Map.Entry<K, V>> entrySet = map.entrySet();
|
||||
Map.Entry<K, V>[] array = (Map.Entry<K, V>[]) entrySet.toArray(new Map.Entry[0]);
|
||||
Map.Entry<K, V>[] array = entrySet.toArray(new Map.Entry[0]);
|
||||
array[0].setValue((V) "66");
|
||||
assertEquals(new Integer(66), array[0].getValue());
|
||||
assertEquals(new Integer(66), map.get(array[0].getKey()));
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.collections.BulkTest;
|
|||
* To use, subclass and override the {@link #makeEmptySet()}
|
||||
* method. You may have to override other protected methods if your
|
||||
* set is not modifiable, or if your set restricts what kinds of
|
||||
* elements may be added; see {@link AbstractTestCollection} for more details.
|
||||
* elements may be added; see {@link AbstractTestSet} for more details.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision$ $Date$
|
||||
|
|
|
@ -28,9 +28,9 @@ import org.apache.commons.collections.collection.CompositeCollection;
|
|||
* class also has to be serialized.
|
||||
*/
|
||||
class EmptySetMutator<E> implements CompositeSet.SetMutator<E> {
|
||||
private Set contained;
|
||||
private Set<E> contained;
|
||||
|
||||
public EmptySetMutator(Set set) {
|
||||
public EmptySetMutator(Set<E> set) {
|
||||
this.contained = set;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TestCompositeSet<E> extends AbstractTestSet<E> {
|
|||
public CompositeSet<E> makeObject() {
|
||||
final HashSet<E> contained = new HashSet<E>();
|
||||
CompositeSet<E> set = new CompositeSet<E>(contained);
|
||||
set.setMutator( new EmptySetMutator(contained) );
|
||||
set.setMutator( new EmptySetMutator<E>(contained) );
|
||||
return set;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,12 +97,12 @@ public class TestTransformedSet<E> extends AbstractTestSet<E> {
|
|||
}
|
||||
|
||||
public void testTransformedSet_decorateTransform() {
|
||||
Set originalSet = new HashSet();
|
||||
Set<Object> originalSet = new HashSet<Object>();
|
||||
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
|
||||
for (int i = 0; i < els.length; i++) {
|
||||
originalSet.add(els[i]);
|
||||
}
|
||||
Set set = TransformedSet.decorateTransform(originalSet, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
|
||||
Set<?> set = TransformedSet.decorateTransform(originalSet, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
|
||||
assertEquals(els.length, set.size());
|
||||
for (int i = 0; i < els.length; i++) {
|
||||
assertEquals(true, set.contains(new Integer((String) els[i])));
|
||||
|
|
|
@ -83,12 +83,12 @@ public class TestTransformedSortedSet<E> extends AbstractTestSortedSet<E> {
|
|||
}
|
||||
|
||||
public void testTransformedSet_decorateTransform() {
|
||||
Set originalSet = new TreeSet();
|
||||
Set<Object> originalSet = new TreeSet<Object>();
|
||||
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
|
||||
for (int i = 0; i < els.length; i++) {
|
||||
originalSet.add(els[i]);
|
||||
}
|
||||
Set set = TransformedSortedSet.decorateTransform(originalSet, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
|
||||
Set<?> set = TransformedSortedSet.decorateTransform(originalSet, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
|
||||
assertEquals(els.length, set.size());
|
||||
for (int i = 0; i < els.length; i++) {
|
||||
assertEquals(true, set.contains(new Integer((String) els[i])));
|
||||
|
|
|
@ -42,7 +42,7 @@ public class TestTransformedMap extends BulkTest {
|
|||
private Transformer<Integer, String> intToString = new Transformer<Integer, String>() {
|
||||
public String transform(Integer input) {
|
||||
return String.valueOf(input);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
private Transformer<Object, Class<?>> objectToClass = new Transformer<Object, Class<?>>() {
|
||||
|
@ -71,13 +71,12 @@ public class TestTransformedMap extends BulkTest {
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testTransformedMap() {
|
||||
TransformedMap<Integer, String, Object, Class<?>> map = TransformedMap.decorate(
|
||||
new HashMap<String, Class<?>>(), intToString, objectToClass);
|
||||
|
||||
Integer[] k = new Integer[] { 0, 1, 2, 3, 4, 5, 6 };
|
||||
Object[] v = new Object[] { "", new Object(), new HashMap(), 0, BigInteger.TEN, null,
|
||||
Object[] v = new Object[] { "", new Object(), new HashMap<Object, Object>(), 0, BigInteger.TEN, null,
|
||||
new Object[0] };
|
||||
|
||||
assertEquals(0, map.size());
|
||||
|
|
Loading…
Reference in New Issue