diff --git a/src/java/org/apache/commons/collections/CollectionUtils.java b/src/java/org/apache/commons/collections/CollectionUtils.java index 4d26462c1..1d674f5d1 100644 --- a/src/java/org/apache/commons/collections/CollectionUtils.java +++ b/src/java/org/apache/commons/collections/CollectionUtils.java @@ -386,10 +386,10 @@ public class CollectionUtils { * @return the the number of occurrences of obj in coll */ public static int cardinality(O obj, final Iterable coll) { - if (coll instanceof Set) { + if (coll instanceof Set) { return (((Set) coll).contains(obj) ? 1 : 0); } - if (coll instanceof Bag) { + if (coll instanceof Bag) { return ((Bag) coll).getCount(obj); } int count = 0; @@ -492,7 +492,7 @@ public class CollectionUtils { public static void transform(Collection collection, Transformer transformer) { if (collection != null && transformer != null) { - if (collection instanceof List) { + if (collection instanceof List) { List list = (List) collection; for (ListIterator it = list.listIterator(); it.hasNext();) { it.set(transformer.transform(it.next())); @@ -703,7 +703,7 @@ public class CollectionUtils { * @param outputCollection the collection to output into, may not be null * @param the type of object in the input collection * @param the type of object in the output collection - * @param the output type of the transformer - this extends O. + * @param the output type of the transformer - this extends O. * @return the outputCollection with the transformed input added * @throws NullPointerException if the output collection is null */ @@ -727,7 +727,7 @@ public class CollectionUtils { * @param outputCollection the collection to output into, may not be null * @param the type of object in the input collection * @param the type of object in the output collection - * @param the output type of the transformer - this extends O. + * @param the output type of the transformer - this extends O. * @return the outputCollection with the transformed input added * @throws NullPointerException if the output collection is null */ @@ -772,7 +772,7 @@ public class CollectionUtils { * if the collection or iterator is null */ public static boolean addAll(Collection collection, Iterable iterable) { - if (iterable instanceof Collection) { + if (iterable instanceof Collection) { return collection.addAll((Collection) iterable); } return addAll(collection, iterable.iterator()); @@ -879,7 +879,7 @@ public class CollectionUtils { */ public static T get(Iterable iterable, int index) { checkIndexBounds(index); - if (iterable instanceof List) { + if (iterable instanceof List) { return ((List) iterable).get(index); } return get(iterable.iterator(), index); @@ -920,13 +920,13 @@ public class CollectionUtils { if (i < 0) { throw new IndexOutOfBoundsException("Index cannot be negative: " + i); } - if (object instanceof Map) { + if (object instanceof Map) { Map map = (Map) object; Iterator iterator = map.entrySet().iterator(); return get(iterator, i); } else if (object instanceof Object[]) { return ((Object[]) object)[i]; - } else if (object instanceof Iterator) { + } else if (object instanceof Iterator) { Iterator it = (Iterator) object; while (it.hasNext()) { i--; @@ -936,10 +936,10 @@ public class CollectionUtils { it.next(); } throw new IndexOutOfBoundsException("Entry does not exist: " + i); - } else if (object instanceof Collection) { + } else if (object instanceof Collection) { Iterator iterator = ((Collection) object).iterator(); return get(iterator, i); - } else if (object instanceof Enumeration) { + } else if (object instanceof Enumeration) { Enumeration it = (Enumeration) object; while (it.hasMoreElements()) { i--; @@ -994,19 +994,19 @@ public class CollectionUtils { */ public static int size(Object object) { int total = 0; - if (object instanceof Map) { + if (object instanceof Map) { total = ((Map) object).size(); - } else if (object instanceof Collection) { + } else if (object instanceof Collection) { total = ((Collection) object).size(); } else if (object instanceof Object[]) { total = ((Object[]) object).length; - } else if (object instanceof Iterator) { + } else if (object instanceof Iterator) { Iterator it = (Iterator) object; while (it.hasNext()) { total++; it.next(); } - } else if (object instanceof Enumeration) { + } else if (object instanceof Enumeration) { Enumeration it = (Enumeration) object; while (it.hasMoreElements()) { total++; @@ -1045,15 +1045,15 @@ public class CollectionUtils { * @since Commons Collections 3.2 */ public static boolean sizeIsEmpty(Object object) { - if (object instanceof Collection) { + if (object instanceof Collection) { return ((Collection) object).isEmpty(); - } else if (object instanceof Map) { + } else if (object instanceof Map) { return ((Map) object).isEmpty(); } else if (object instanceof Object[]) { return ((Object[]) object).length == 0; - } else if (object instanceof Iterator) { + } else if (object instanceof Iterator) { return ((Iterator) object).hasNext() == false; - } else if (object instanceof Enumeration) { + } else if (object instanceof Enumeration) { return ((Enumeration) object).hasMoreElements() == false; } else if (object == null) { throw new IllegalArgumentException("Unsupported object type: null");