Suppress "rawtypes" warnings in CollectionFactory

This commit also adds links to the newly created Eclipse bug that was
raised for this issue.
This commit is contained in:
Sam Brannen
2014-12-09 21:29:05 +01:00
parent fe78900524
commit d8ef666764

View File

@@ -105,7 +105,7 @@ public abstract class CollectionFactory {
* @see java.util.ArrayList
* @see java.util.LinkedList
*/
@SuppressWarnings({ "unchecked", "cast" })
@SuppressWarnings({ "unchecked", "cast", "rawtypes" })
public static <E> Collection<E> createApproximateCollection(Object collection, int capacity) {
if (collection instanceof LinkedList) {
return new LinkedList<E>();
@@ -115,6 +115,7 @@ public abstract class CollectionFactory {
}
else if (collection instanceof EnumSet) {
// superfluous cast necessary for bug in Eclipse 4.4.1.
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=454644
return (Collection<E>) EnumSet.copyOf((EnumSet) collection);
}
else if (collection instanceof SortedSet) {
@@ -150,7 +151,7 @@ public abstract class CollectionFactory {
* @see java.util.EnumSet
* @see java.util.ArrayList
*/
@SuppressWarnings({ "unchecked", "cast" })
@SuppressWarnings({ "unchecked", "cast", "rawtypes" })
public static <E> Collection<E> createCollection(Class<?> collectionClass, Class<?> elementType, int capacity) {
if (collectionClass.isInterface()) {
if (Set.class.equals(collectionClass) || Collection.class.equals(collectionClass)) {
@@ -169,6 +170,7 @@ public abstract class CollectionFactory {
else if (EnumSet.class.equals(collectionClass)) {
Assert.notNull(elementType, "Cannot create EnumSet for unknown element type");
// superfluous cast necessary for bug in Eclipse 4.4.1.
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=454644
return (Collection<E>) EnumSet.noneOf((Class) elementType);
}
else {