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