avoid some generic array classcastexceptions

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@825140 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2009-10-14 14:04:46 +00:00
parent 2c5a64eec4
commit d1eecac1f6
1 changed files with 9 additions and 2 deletions

View File

@ -46,9 +46,13 @@ public abstract class AbstractTestSortedBidiMap<K extends Comparable<K>, V exten
protected List<V> sortedValues = new ArrayList<V>();
protected SortedSet<V> sortedNewValues = new TreeSet<V>();
@SuppressWarnings("unchecked")
public AbstractTestSortedBidiMap(String testName) {
super(testName);
sortedKeys.addAll(Arrays.asList(getSampleKeys()));
Object[] sampleKeys = getSampleKeys();
for (Object key : sampleKeys) {
sortedKeys.add((K) key);
}
Collections.sort(sortedKeys);
sortedKeys = Collections.unmodifiableList(sortedKeys);
@ -58,7 +62,10 @@ public abstract class AbstractTestSortedBidiMap<K extends Comparable<K>, V exten
sortedValues.addAll(map.values());
sortedValues = Collections.unmodifiableList(sortedValues);
sortedNewValues.addAll(Arrays.asList(getNewSampleValues()));
Object[] newSampleValues = getNewSampleValues();
for (Object value : newSampleValues) {
sortedNewValues.add((V) value);
}
}
// public AbstractTestSortedBidiMap() {