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

ru.yandex.bolts.collection.impl.UnmodifiableDefaultIteratorF Maven / Gradle / Ivy

The newest version!
package ru.yandex.bolts.collection.impl;

import java.util.Iterator;

import ru.yandex.bolts.collection.IteratorF;
import ru.yandex.bolts.collection.Unmodifiable;


public class UnmodifiableDefaultIteratorF extends DefaultIteratorF implements Unmodifiable {
    protected UnmodifiableDefaultIteratorF(Iterator target) {
        super(target);
    }

    public IteratorF unmodifiable() {
        return this;
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException("immutable");
    }

    public static  IteratorF wrap(Iterator iterator) {
        if (iterator instanceof IteratorF && iterator instanceof Unmodifiable) return (IteratorF) iterator;
        else return new UnmodifiableDefaultIteratorF<>(iterator);
    }
} //~




© 2015 - 2024 Weber Informatics LLC | Privacy Policy