/*
 * @(#)EnumIterator.java  1.2  2010-01-03
 *
 * Copyright (c) 2001-2010 Werner Randelshofer, Immensee, Switzerland.
 * All rights reserved.
 *
 * You may not use, copy or modify this file, except in compliance with the
 * license agreement you entered into with Werner Randelshofer.
 * For details see accompanying license terms.
 */

package ch.randelshofer.util;
import java.util.*;

/**
 * Wraps an Enumeratin with the Iterator interface.
 *
 * @author  Werni Randelshofer
 * @version 1.2 2010-01-03 Generified.
 * <br>1.0 2001-10-08
 */
public class EnumIterator<T> implements java.util.Iterator<T> {
    private Enumeration<T> enumer;
    
    /** Creates new EnumIterator */
    public EnumIterator(Enumeration<T> e) {
        enumer = e;
    }

    @Override
    public boolean hasNext() {
        return enumer.hasMoreElements();
    }
    
    @Override
    public T next() {
        return enumer.nextElement();
    }
    
    /**
     * Throws always UnsupportedOperationException.
     * @exception UnsupportedOperationException
     */
    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
    
}
