[COLLECTIONS-502] remove generic parameters from static INSTANCE fields.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1543964 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
35d4fd2ae7
commit
c00465cc99
|
@ -39,12 +39,14 @@ public class BagUtils {
|
|||
/**
|
||||
* An empty unmodifiable bag.
|
||||
*/
|
||||
public static final Bag<Object> EMPTY_BAG = UnmodifiableBag.unmodifiableBag(new HashBag<Object>());
|
||||
@SuppressWarnings("rawtypes") // OK, empty bag is compatible with any type
|
||||
public static final Bag EMPTY_BAG = UnmodifiableBag.unmodifiableBag(new HashBag<Object>());
|
||||
|
||||
/**
|
||||
* An empty unmodifiable sorted bag.
|
||||
*/
|
||||
public static final Bag<Object> EMPTY_SORTED_BAG =
|
||||
@SuppressWarnings("rawtypes") // OK, empty bag is compatible with any type
|
||||
public static final Bag EMPTY_SORTED_BAG =
|
||||
UnmodifiableSortedBag.unmodifiableSortedBag(new TreeBag<Object>());
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,8 +50,8 @@ public class ComparatorUtils {
|
|||
*
|
||||
* @see ComparableComparator#comparableComparator()
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static final Comparator NATURAL_COMPARATOR = ComparableComparator.<Comparable>comparableComparator();
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Comparator NATURAL_COMPARATOR = ComparableComparator.comparableComparator();
|
||||
|
||||
/**
|
||||
* Gets a comparator that uses the natural order of the objects.
|
||||
|
|
|
@ -85,7 +85,8 @@ public class IteratorUtils {
|
|||
* WARNING: This constant is binary incompatible with Commons Collections 2.1 and 2.1.1.
|
||||
* Use <code>EmptyIterator.INSTANCE</code> for compatibility with Commons Collections 2.1.1.
|
||||
*/
|
||||
public static final ResettableIterator<Object> EMPTY_ITERATOR = EmptyIterator.RESETTABLE_INSTANCE;
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final ResettableIterator EMPTY_ITERATOR = EmptyIterator.RESETTABLE_INSTANCE;
|
||||
|
||||
/**
|
||||
* A list iterator over no elements.
|
||||
|
@ -93,23 +94,26 @@ public class IteratorUtils {
|
|||
* WARNING: This constant is binary incompatible with Commons Collections 2.1 and 2.1.1.
|
||||
* Use <code>EmptyListIterator.INSTANCE</code> for compatibility with Commons Collections 2.1.1.
|
||||
*/
|
||||
public static final ResettableListIterator<Object> EMPTY_LIST_ITERATOR = EmptyListIterator.RESETTABLE_INSTANCE;
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final ResettableListIterator EMPTY_LIST_ITERATOR = EmptyListIterator.RESETTABLE_INSTANCE;
|
||||
|
||||
/**
|
||||
* An ordered iterator over no elements.
|
||||
*/
|
||||
public static final OrderedIterator<Object> EMPTY_ORDERED_ITERATOR = EmptyOrderedIterator.INSTANCE;
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final OrderedIterator EMPTY_ORDERED_ITERATOR = EmptyOrderedIterator.INSTANCE;
|
||||
|
||||
/**
|
||||
* A map iterator over no elements.
|
||||
*/
|
||||
public static final MapIterator<Object, Object> EMPTY_MAP_ITERATOR = EmptyMapIterator.INSTANCE;
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final MapIterator EMPTY_MAP_ITERATOR = EmptyMapIterator.INSTANCE;
|
||||
|
||||
/**
|
||||
* An ordered map iterator over no elements.
|
||||
*/
|
||||
public static final OrderedMapIterator<Object, Object> EMPTY_ORDERED_MAP_ITERATOR =
|
||||
EmptyOrderedMapIterator.INSTANCE;
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final OrderedMapIterator EMPTY_ORDERED_MAP_ITERATOR = EmptyOrderedMapIterator.INSTANCE;
|
||||
|
||||
/**
|
||||
* IteratorUtils is not normally instantiated.
|
||||
|
|
|
@ -80,7 +80,8 @@ public class MapUtils {
|
|||
* An empty unmodifiable sorted map.
|
||||
* This is not provided in the JDK.
|
||||
*/
|
||||
public static final SortedMap<Object, Object> EMPTY_SORTED_MAP =
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final SortedMap EMPTY_SORTED_MAP =
|
||||
UnmodifiableSortedMap.unmodifiableSortedMap(new TreeMap<Object, Object>());
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,8 @@ public class QueueUtils {
|
|||
/**
|
||||
* An empty unmodifiable queue.
|
||||
*/
|
||||
public static final Queue<Object> EMPTY_QUEUE = UnmodifiableQueue.unmodifiableQueue(new LinkedList<Object>());
|
||||
@SuppressWarnings("rawtypes") // OK, empty queue is compatible with any type
|
||||
public static final Queue EMPTY_QUEUE = UnmodifiableQueue.unmodifiableQueue(new LinkedList<Object>());
|
||||
|
||||
/**
|
||||
* <code>QueueUtils</code> should not normally be instantiated.
|
||||
|
|
|
@ -52,7 +52,8 @@ public class SetUtils {
|
|||
* An empty unmodifiable sorted set.
|
||||
* This is not provided in the JDK.
|
||||
*/
|
||||
public static final SortedSet<?> EMPTY_SORTED_SET =
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final SortedSet EMPTY_SORTED_SET =
|
||||
UnmodifiableSortedSet.unmodifiableSortedSet(new TreeSet<Object>());
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class StringValueTransformer<T> implements Transformer<T, String>,
|
|||
private static final long serialVersionUID = 7511110693171758606L;
|
||||
|
||||
/** Singleton predicate instance */
|
||||
public static final Transformer<Object, String> INSTANCE = new StringValueTransformer<Object>();
|
||||
private static final Transformer<Object, String> INSTANCE = new StringValueTransformer<Object>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -507,11 +507,11 @@ public class IteratorUtilsTest extends BulkTest {
|
|||
fail();
|
||||
} catch (final IllegalStateException ex) {}
|
||||
try {
|
||||
IteratorUtils.EMPTY_LIST_ITERATOR.set(null);
|
||||
IteratorUtils.emptyListIterator().set(null);
|
||||
fail();
|
||||
} catch (final IllegalStateException ex) {}
|
||||
try {
|
||||
IteratorUtils.EMPTY_LIST_ITERATOR.add(null);
|
||||
IteratorUtils.emptyListIterator().add(null);
|
||||
fail();
|
||||
} catch (final UnsupportedOperationException ex) {}
|
||||
}
|
||||
|
|
|
@ -426,7 +426,7 @@ public class TransformerUtilsTest extends junit.framework.TestCase {
|
|||
//------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Test that all Transformer singletones hold singleton pattern in
|
||||
* Test that all Transformer singletons hold singleton pattern in
|
||||
* serialization/deserialization process.
|
||||
*/
|
||||
public void testSingletonPatternInSerialization() {
|
||||
|
@ -434,14 +434,11 @@ public class TransformerUtilsTest extends junit.framework.TestCase {
|
|||
CloneTransformer.INSTANCE,
|
||||
ExceptionTransformer.INSTANCE,
|
||||
NOPTransformer.INSTANCE,
|
||||
StringValueTransformer.INSTANCE,
|
||||
StringValueTransformer.stringValueTransformer(),
|
||||
};
|
||||
|
||||
for (final Object original : singletones) {
|
||||
TestUtils.assertSameAfterSerialization(
|
||||
"Singletone patern broken for " + original.getClass(),
|
||||
original
|
||||
);
|
||||
TestUtils.assertSameAfterSerialization("Singleton pattern broken for " + original.getClass(), original);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ public class ObjectArrayIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
return new ObjectArrayIterator<E>((E[]) testArray);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ObjectArrayIterator<E> makeArrayIterator() {
|
||||
return new ObjectArrayIterator<E>();
|
||||
}
|
||||
|
|
|
@ -305,6 +305,7 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
|||
|
||||
public void testPutAllWithIndex() {
|
||||
resetEmpty();
|
||||
@SuppressWarnings("unchecked")
|
||||
final ListOrderedMap<String, String> lom = (ListOrderedMap<String, String>) map;
|
||||
|
||||
// Create Initial Data
|
||||
|
@ -329,6 +330,7 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
|||
assertEquals("testInsert2v", lom.getValue(4));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testPutAllWithIndexBug441() {
|
||||
// see COLLECTIONS-441
|
||||
resetEmpty();
|
||||
|
|
|
@ -276,6 +276,7 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testPutWithList() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
final MultiValueMap<K, V> test = MultiValueMap.multiValueMap(new HashMap<K, Collection>(), ArrayList.class);
|
||||
assertEquals("a", test.put((K) "A", "a"));
|
||||
assertEquals("b", test.put((K) "A", "b"));
|
||||
|
@ -286,6 +287,7 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testPutWithSet() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
final MultiValueMap<K, V> test = MultiValueMap.multiValueMap(new HashMap<K, HashSet>(), HashSet.class);
|
||||
assertEquals("a", test.put((K) "A", "a"));
|
||||
assertEquals("b", test.put((K) "A", "b"));
|
||||
|
|
|
@ -46,7 +46,7 @@ public class TransformedMapTest<K, V> extends AbstractIterableMapTest<K, V> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void testTransformedMap() {
|
||||
final Object[] els = new Object[] { "1", "3", "5", "7", "2", "4", "6" };
|
||||
|
||||
|
|
Loading…
Reference in New Issue