com.darwinsys.util.IteratorEnumerationBridge Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of darwinsys-api Show documentation
Show all versions of darwinsys-api Show documentation
Ian Darwin's assorted Java stuff,
assembled as an API.
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();
}
}