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
This commit is contained in:
parent
550d30609f
commit
bac08c04d4
|
@ -132,7 +132,7 @@ public class CollectionUtils {
|
||||||
* @param <T> the element type
|
* @param <T> the element type
|
||||||
* @return immutable empty collection
|
* @return immutable empty collection
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked") // OK, empty collection is compatible with any type
|
||||||
public static <T> Collection<T> emptyCollection() {
|
public static <T> Collection<T> emptyCollection() {
|
||||||
return EMPTY_COLLECTION;
|
return EMPTY_COLLECTION;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public class CollectionUtils {
|
||||||
* @param collection the collection, possibly <code>null</code>
|
* @param collection the collection, possibly <code>null</code>
|
||||||
* @return an empty collection if the argument is <code>null</code>
|
* @return an empty collection if the argument is <code>null</code>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked") // OK, empty collection is compatible with any type
|
||||||
public static <T> Collection<T> emptyIfNull(final Collection<T> collection) {
|
public static <T> Collection<T> emptyIfNull(final Collection<T> collection) {
|
||||||
return collection == null ? EMPTY_COLLECTION : collection;
|
return collection == null ? EMPTY_COLLECTION : collection;
|
||||||
}
|
}
|
||||||
|
@ -1205,8 +1205,7 @@ public class CollectionUtils {
|
||||||
* @return true if the BoundedCollection is full
|
* @return true if the BoundedCollection is full
|
||||||
* @throws NullPointerException if the collection is null
|
* @throws NullPointerException if the collection is null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
public static boolean isFull(final Collection<? extends Object> coll) {
|
||||||
public static boolean isFull(final Collection<?> coll) {
|
|
||||||
if (coll == null) {
|
if (coll == null) {
|
||||||
throw new NullPointerException("The collection must not be null");
|
throw new NullPointerException("The collection must not be null");
|
||||||
}
|
}
|
||||||
|
@ -1215,7 +1214,7 @@ public class CollectionUtils {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final BoundedCollection<?> bcoll =
|
final BoundedCollection<?> bcoll =
|
||||||
UnmodifiableBoundedCollection.unmodifiableBoundedCollection((Collection<Object>) coll);
|
UnmodifiableBoundedCollection.unmodifiableBoundedCollection(coll);
|
||||||
return bcoll.isFull();
|
return bcoll.isFull();
|
||||||
} catch (final IllegalArgumentException ex) {
|
} catch (final IllegalArgumentException ex) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1237,8 +1236,7 @@ public class CollectionUtils {
|
||||||
* @return the maximum size of the BoundedCollection, -1 if no maximum size
|
* @return the maximum size of the BoundedCollection, -1 if no maximum size
|
||||||
* @throws NullPointerException if the collection is null
|
* @throws NullPointerException if the collection is null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
public static int maxSize(final Collection<? extends Object> coll) {
|
||||||
public static int maxSize(final Collection<?> coll) {
|
|
||||||
if (coll == null) {
|
if (coll == null) {
|
||||||
throw new NullPointerException("The collection must not be null");
|
throw new NullPointerException("The collection must not be null");
|
||||||
}
|
}
|
||||||
|
@ -1247,7 +1245,7 @@ public class CollectionUtils {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final BoundedCollection<?> bcoll =
|
final BoundedCollection<?> bcoll =
|
||||||
UnmodifiableBoundedCollection.unmodifiableBoundedCollection((Collection<Object>) coll);
|
UnmodifiableBoundedCollection.unmodifiableBoundedCollection(coll);
|
||||||
return bcoll.maxSize();
|
return bcoll.maxSize();
|
||||||
} catch (final IllegalArgumentException ex) {
|
} catch (final IllegalArgumentException ex) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue