From 19a707c06ded92cd315cfd2b4fc78797f2395050 Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Wed, 26 May 2004 21:56:45 +0000 Subject: [PATCH] Ensure empty iterator implementation is as per v3.0 git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131753 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/collections/IteratorUtils.java | 21 ++++++++++--------- .../collections/TestIteratorUtils.java | 6 ++++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/java/org/apache/commons/collections/IteratorUtils.java b/src/java/org/apache/commons/collections/IteratorUtils.java index 4baacfa81..c759b70a2 100644 --- a/src/java/org/apache/commons/collections/IteratorUtils.java +++ b/src/java/org/apache/commons/collections/IteratorUtils.java @@ -33,6 +33,7 @@ import org.apache.commons.collections.iterators.CollatingIterator; import org.apache.commons.collections.iterators.EmptyIterator; import org.apache.commons.collections.iterators.EmptyListIterator; import org.apache.commons.collections.iterators.EmptyMapIterator; +import org.apache.commons.collections.iterators.EmptyOrderedIterator; import org.apache.commons.collections.iterators.EmptyOrderedMapIterator; import org.apache.commons.collections.iterators.EnumerationIterator; import org.apache.commons.collections.iterators.FilterIterator; @@ -63,7 +64,7 @@ import org.apache.commons.collections.iterators.UnmodifiableMapIterator; * against versions 2.1.1 and 3.1. * * @since Commons Collections 2.1 - * @version $Revision: 1.26 $ $Date: 2004/05/22 09:46:39 $ + * @version $Revision: 1.27 $ $Date: 2004/05/26 21:53:46 $ * * @author Stephen Colebourne * @author Phil Steitz @@ -75,21 +76,21 @@ public class IteratorUtils { /** * An iterator over no elements. *

- * WARNING: This constant is binary incompatible with Commons Collections 2.1. + * WARNING: This constant is binary incompatible with Commons Collections 2.1 and 2.1.1. * Use EmptyIterator.INSTANCE for compatability with Commons Collections 2.1.1. */ public static final ResettableIterator EMPTY_ITERATOR = EmptyIterator.RESETTABLE_INSTANCE; /** * A list iterator over no elements. *

- * WARNING: This constant is binary incompatible with Commons Collections 2.1. + * WARNING: This constant is binary incompatible with Commons Collections 2.1 and 2.1.1. * Use EmptyListIterator.INSTANCE for compatability with Commons Collections 2.1.1. */ public static final ResettableListIterator EMPTY_LIST_ITERATOR = EmptyListIterator.RESETTABLE_INSTANCE; /** * An ordered iterator over no elements. */ - public static final OrderedIterator EMPTY_ORDERED_ITERATOR = EmptyListIterator.ORDERED_INSTANCE; + public static final OrderedIterator EMPTY_ORDERED_ITERATOR = EmptyOrderedIterator.INSTANCE; /** * A map iterator over no elements. */ @@ -113,7 +114,7 @@ public class IteratorUtils { * This iterator is a valid iterator object that will iterate over * nothing. *

- * WARNING: This method is binary incompatible with Commons Collections 2.1. + * WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1. * Use EmptyIterator.INSTANCE for compatability with Commons Collections 2.1.1. * * @return an iterator over nothing @@ -128,7 +129,7 @@ public class IteratorUtils { * This iterator is a valid list iterator object that will iterate * over nothing. *

- * WARNING: This method is binary incompatible with Commons Collections 2.1. + * WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1. * Use EmptyListIterator.INSTANCE for compatability with Commons Collections 2.1.1. * * @return a list iterator over nothing @@ -181,7 +182,7 @@ public class IteratorUtils { * This iterator is a valid iterator object that will iterate over * the specified object. *

- * WARNING: This method is binary incompatible with Commons Collections 2.1. + * WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1. * Use new SingletonIterator(object) for compatability. * * @param object the single object over which to iterate @@ -209,7 +210,7 @@ public class IteratorUtils { /** * Gets an iterator over an object array. *

- * WARNING: This method is binary incompatible with Commons Collections 2.1. + * WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1. * Use new ArrayIterator(array) for compatability. * * @param array the array over which to iterate @@ -238,7 +239,7 @@ public class IteratorUtils { /** * Gets an iterator over the end part of an object array. *

- * WARNING: This method is binary incompatible with Commons Collections 2.1. + * WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1. * Use new ArrayIterator(array,start) for compatability. * * @param array the array over which to iterate @@ -273,7 +274,7 @@ public class IteratorUtils { /** * Gets an iterator over part of an object array. *

- * WARNING: This method is binary incompatible with Commons Collections 2.1. + * WARNING: This method is binary incompatible with Commons Collections 2.1 and 2.1.1. * Use new ArrayIterator(array,start,end) for compatability. * * @param array the array over which to iterate diff --git a/src/test/org/apache/commons/collections/TestIteratorUtils.java b/src/test/org/apache/commons/collections/TestIteratorUtils.java index 41339b4c4..e1e3f9b79 100644 --- a/src/test/org/apache/commons/collections/TestIteratorUtils.java +++ b/src/test/org/apache/commons/collections/TestIteratorUtils.java @@ -27,12 +27,13 @@ import junit.framework.Test; import org.apache.commons.collections.iterators.EmptyIterator; import org.apache.commons.collections.iterators.EmptyListIterator; import org.apache.commons.collections.iterators.EmptyMapIterator; +import org.apache.commons.collections.iterators.EmptyOrderedIterator; import org.apache.commons.collections.iterators.EmptyOrderedMapIterator; /** * Tests for IteratorUtils. * - * @version $Revision: 1.15 $ $Date: 2004/05/22 09:46:39 $ + * @version $Revision: 1.16 $ $Date: 2004/05/26 21:56:45 $ * * @author Unknown */ @@ -493,10 +494,11 @@ public class TestIteratorUtils extends BulkTest { * Test empty map iterator */ public void testEmptyOrderedIterator() { - assertSame(EmptyListIterator.ORDERED_INSTANCE, IteratorUtils.EMPTY_ORDERED_ITERATOR); + assertSame(EmptyOrderedIterator.INSTANCE, IteratorUtils.EMPTY_ORDERED_ITERATOR); assertEquals(true, IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof Iterator); assertEquals(true, IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof OrderedIterator); assertEquals(true, IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof ResettableIterator); + assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof ListIterator); assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof MapIterator); assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR.hasNext()); assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR.hasPrevious());