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

com.github.xphsc.collect.iterator.AbstractEmptyIterator Maven / Gradle / Ivy

There is a newer version: 1.2.3
Show newest version
package com.github.xphsc.collect.iterator;

import java.util.NoSuchElementException;

/**
 * Created by ${huipei.x} on 2017-8-7.
 */
public class AbstractEmptyIterator {
    protected AbstractEmptyIterator() {
    }

    public boolean hasNext() {
        return false;
    }

    public E next() {
        throw new NoSuchElementException("Iterator contains no elements");
    }

    public boolean hasPrevious() {
        return false;
    }

    public E previous() {
        throw new NoSuchElementException("Iterator contains no elements");
    }

    public int nextIndex() {
        return 0;
    }

    public int previousIndex() {
        return -1;
    }

    public void add(E obj) {
        throw new UnsupportedOperationException("add() not supported for empty Iterator");
    }

    public void set(E obj) {
        throw new IllegalStateException("Iterator contains no elements");
    }

    public void remove() {
        throw new IllegalStateException("Iterator contains no elements");
    }

    public void reset() {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy