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
This commit is contained in:
Stephen Colebourne 2004-05-26 21:56:45 +00:00
parent bfd55bc3ad
commit 19a707c06d
2 changed files with 15 additions and 12 deletions

View File

@ -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.
* <p>
* 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 <code>EmptyIterator.INSTANCE</code> for compatability with Commons Collections 2.1.1.
*/
public static final ResettableIterator EMPTY_ITERATOR = EmptyIterator.RESETTABLE_INSTANCE;
/**
* A list iterator over no elements.
* <p>
* 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 <code>EmptyListIterator.INSTANCE</code> 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.
* <p>
* 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 <code>EmptyIterator.INSTANCE</code> 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.
* <p>
* 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 <code>EmptyListIterator.INSTANCE</code> 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.
* <p>
* 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 <code>new SingletonIterator(object)</code> 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.
* <p>
* 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 <code>new ArrayIterator(array)</code> 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.
* <p>
* 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 <code>new ArrayIterator(array,start)</code> 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.
* <p>
* 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 <code>new ArrayIterator(array,start,end)</code> for compatability.
*
* @param array the array over which to iterate

View File

@ -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());