/*
 * Copyright (C) 2009  Christian Hujer.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

package net.sf.japi.util;

import java.util.Enumeration;
import java.util.Iterator;
import org.jetbrains.annotations.NotNull;

/** Enumeration proxy for Iterators.
 * Instances are not reusable.
 * @param <E> Enumeration / Iterator element type.
 * @author <a href="mailto:cher@riedquat.de">Christian Hujer</a>
 * @since 0.1
 */
public class IteratorEnumeration<E> implements Enumeration<E> {

    /** Iterator to enumerate. */
    @NotNull private final Iterator<E> iterator;

    /** Create an Enumeration for an Iterator.
     * @param iterator Iterator to create Enumeration for
     */
    public IteratorEnumeration(@NotNull final Iterator<E> iterator) {
        this.iterator = iterator;
    }

    /** {@inheritDoc} */
    public boolean hasMoreElements() {
        return iterator.hasNext();
    }

    /** {@inheritDoc} */
    public E nextElement() {
        return iterator.next();
    }

} // class IteratorEnumeration
