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

com.jn.langx.util.collection.iter.WrappedIterator Maven / Gradle / Ivy

Go to download

Java lang extensions for java6+, a supplement to , replacement of a Guava, commons-lang. Core utilities, Collection utilities, IO utilities, Cache, Configuration library ...

There is a newer version: 4.8.2
Show newest version
package com.jn.langx.util.collection.iter;

import com.jn.langx.annotation.NonNull;
import com.jn.langx.util.Preconditions;

import java.util.Iterator;

public class WrappedIterator implements Iterator {
    private Iterator delegate;
    private boolean mutable;

    public WrappedIterator(@NonNull Iterator delegate, boolean mutable) {
        Preconditions.checkNotNull(delegate);
        this.delegate = delegate;
        this.mutable = mutable;
    }

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

    @Override
    public E next() {
        return delegate.next();
    }

    @Override
    public void remove() {
        if (!mutable) {
            throw new UnsupportedOperationException("Unsupported remove() on an immutable iterator");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy