All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.darwinsys.util.IteratorEnumerationBridge Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
package com.darwinsys.util;

import java.util.Enumeration;
import java.util.Iterator;

/**
 * Make instances of newer Iterator look like older Enumeration,
 * for some kind of backwards compatibility.
 */
public class IteratorEnumerationBridge implements Enumeration {

	private final Iterator it;

	public IteratorEnumerationBridge(Iterator it) {
		this.it = it;
	}

	/** Tell whether this Enumeration has more elements 
	 * @see java.util.Enumeration#hasMoreElements()
	 */
	public boolean hasMoreElements() {
		return it.hasNext();
	}

	/** Get the next element from this Enumeration; can
	 * only be called if hasMoreElements() is true. 
	 * @see java.util.Enumeration#nextElement()
	 */
	public T nextElement() {
		return it.next();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy