aQute.lib.collections.EnumerationIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bnd Show documentation
Show all versions of bnd Show documentation
A command line utility and Ant plugin to wrap, build, or examine bundles.
package aQute.lib.collections;
import java.util.*;
/**
* Simple facade for enumerators so they can be used in for loops.
*
* @param
*/
public class EnumerationIterator implements Iterable, Iterator {
public static EnumerationIterator iterator(Enumeration e) {
return new EnumerationIterator(e);
}
final Enumeration enumerator;
volatile boolean done = false;
public EnumerationIterator(Enumeration e) {
enumerator = e;
}
public synchronized Iterator iterator() {
if (done)
throw new IllegalStateException("Can only be used once");
done = true;
return this;
}
public boolean hasNext() {
return enumerator.hasMoreElements();
}
public T next() {
return enumerator.nextElement();
}
public void remove() {
throw new UnsupportedOperationException("Does not support removes");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy