All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bigdata.striterator.ClosableSingleItemIterator Maven / Gradle / Ivy

package com.bigdata.striterator;

import java.util.NoSuchElementException;

import cutthecrap.utils.striterators.ICloseableIterator;



/**
 * A closable iterator that visits a single item.
 * 
 * @author Bryan Thompson
 * @version $Id$
 * @param 
 */
public class ClosableSingleItemIterator implements ICloseableIterator {

    private boolean done = false;
    
    private final E element;
    
    public ClosableSingleItemIterator(E element) {
        
        this.element = element;
        
    }
    
    public void close() {
        // NOP
    }

    public boolean hasNext() {
    
        return !done;
        
    }

    public E next() {
        
        if(!hasNext()) throw new NoSuchElementException();
        
        done = true;
        
        return element;
    }

    public void remove() {

        throw new UnsupportedOperationException();
        
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy