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

htsjdk.samtools.util.DelegatingIterator Maven / Gradle / Ivy

There is a newer version: 4.1.3
Show newest version
package htsjdk.samtools.util;

import java.util.Iterator;

/**
 * Simple iterator class that delegates all method calls to an underlying iterator. Useful
 * for in-line subclassing to add behaviour to one or more methods.
 *
 * @author Tim Fennell
 */
public class DelegatingIterator implements CloseableIterator {
    private final Iterator iterator;

    public DelegatingIterator(final Iterator iterator) {
        this.iterator = iterator;
    }

    @Override
    public void close() {
        if (iterator instanceof CloseableIterator) {
            ((CloseableIterator) this.iterator).close();
        }
    }

    @Override
    public boolean hasNext() {
        return this.iterator.hasNext();
    }

    @Override
    public T next() {
        return this.iterator.next();
    }

    @Override
    public void remove() {
        this.iterator.remove();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy