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

com.fasterxml.jackson.databind.util.EmptyIterator Maven / Gradle / Ivy

Go to download

Ehcache is an open source, standards-based cache used to boost performance, offload the database and simplify scalability. Ehcache is robust, proven and full-featured and this has made it the most widely-used Java-based cache.

There is a newer version: 2.10.9.2
Show newest version
package com.fasterxml.jackson.databind.util;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * Implementation of {@link Iterator} for Empty collections.
 * While JDK has an implementation starting with 1.7, we need this
 * class until then.
 * 
 * @since 2.2 (before, we had embedded instances)
 */
public class EmptyIterator implements Iterator
{
    private final static EmptyIterator instance = new EmptyIterator();

    private EmptyIterator() { }

    @SuppressWarnings("unchecked")
    public static  Iterator instance() {
        return (Iterator) instance;
    }
    
    @Override
    public boolean hasNext() { return false; }
    @Override
    public T next() { throw new NoSuchElementException(); }

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