
package org.apache.lenya.cms.site;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

import org.apache.commons.lang.Validate;

/**
 * Node iterator.
 */
public class NodeIterator {

    private Iterator delegate;
    
    /**
     * @param collection The collection to iterate over.
     */
    public NodeIterator(Collection collection) {
        Validate.notNull(collection);
        this.delegate = collection.iterator();
    }
    
    /**
     * @param nodes The nodes to iterate over.
     */
    public NodeIterator(SiteNode[] nodes) {
    	Validate.notNull(nodes);
        this.delegate = Arrays.asList(nodes).iterator();
    }
    
    /**
     * @return A site node.
     * @see Iterator#next()
     */
    public SiteNode next() {
        return (SiteNode) this.delegate.next();
    }
    
    /**
     * @return A boolean value.
     * @see Iterator#hasNext()
     */
    public boolean hasNext() {
        return this.delegate.hasNext();
    }
    
}
