From bac08c04d4bcd15c20979cc9a37749247467a054 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Mon, 21 Jan 2013 01:15:51 +0000 Subject: [PATCH] Document and fix some unchecked casts git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1436053 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/collections/CollectionUtils.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/commons/collections/CollectionUtils.java b/src/main/java/org/apache/commons/collections/CollectionUtils.java index 7ea2624c7..de44835af 100644 --- a/src/main/java/org/apache/commons/collections/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections/CollectionUtils.java @@ -132,7 +132,7 @@ public class CollectionUtils { * @param the element type * @return immutable empty collection */ - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // OK, empty collection is compatible with any type public static Collection emptyCollection() { return EMPTY_COLLECTION; } @@ -145,7 +145,7 @@ public class CollectionUtils { * @param collection the collection, possibly null * @return an empty collection if the argument is null */ - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // OK, empty collection is compatible with any type public static Collection emptyIfNull(final Collection collection) { return collection == null ? EMPTY_COLLECTION : collection; } @@ -1205,8 +1205,7 @@ public class CollectionUtils { * @return true if the BoundedCollection is full * @throws NullPointerException if the collection is null */ - @SuppressWarnings("unchecked") - public static boolean isFull(final Collection coll) { + public static boolean isFull(final Collection coll) { if (coll == null) { throw new NullPointerException("The collection must not be null"); } @@ -1215,7 +1214,7 @@ public class CollectionUtils { } try { final BoundedCollection bcoll = - UnmodifiableBoundedCollection.unmodifiableBoundedCollection((Collection) coll); + UnmodifiableBoundedCollection.unmodifiableBoundedCollection(coll); return bcoll.isFull(); } catch (final IllegalArgumentException ex) { return false; @@ -1237,8 +1236,7 @@ public class CollectionUtils { * @return the maximum size of the BoundedCollection, -1 if no maximum size * @throws NullPointerException if the collection is null */ - @SuppressWarnings("unchecked") - public static int maxSize(final Collection coll) { + public static int maxSize(final Collection coll) { if (coll == null) { throw new NullPointerException("The collection must not be null"); } @@ -1247,7 +1245,7 @@ public class CollectionUtils { } try { final BoundedCollection bcoll = - UnmodifiableBoundedCollection.unmodifiableBoundedCollection((Collection) coll); + UnmodifiableBoundedCollection.unmodifiableBoundedCollection(coll); return bcoll.maxSize(); } catch (final IllegalArgumentException ex) { return -1;