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

com.tangosol.coherence.jcache.common.MapEntryIteratorToCacheEntryIteratorAdapter Maven / Gradle / Ivy

There is a newer version: 24.09.2
Show newest version
/*
 * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
 *
 * Licensed under the Universal Permissive License v 1.0 as shown at
 * http://oss.oracle.com/licenses/upl.
 */
package com.tangosol.coherence.jcache.common;

import java.util.Iterator;
import java.util.Map;

import javax.cache.Cache;

/**
 * An adapter that converts an {@link Iterator} over {@link Map} entries
 * into an {@link Iterator} over {@link Cache} entries.
 *
 * @param   the type of the keys
 * @param   the type of the values
 *
 * @author bo  2013.10.24
 * @since Coherence 12.1.3
 */
public class MapEntryIteratorToCacheEntryIteratorAdapter
        implements Iterator>
    {
    // ----- constructors ---------------------------------------------------

    /**
     * Constructs a {@link MapEntryIteratorToCacheEntryIteratorAdapter}
     * that lazily adapts an {@link Iterator} over {@link Map} entries in
     * to an {@link Iterator} over {@link Cache} entries.
     *
     * @param iterMap the {@link Map} entry {@link Iterator}
     */
    public MapEntryIteratorToCacheEntryIteratorAdapter(Iterator> iterMap)
        {
        m_iterMap = iterMap;
        }

    // ----- Iterator interface ------------------------------------------

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

    @Override
    public Cache.Entry next()
        {
        return new CoherenceCacheEntry(m_iterMap.next());
        }

    @Override
    public void remove()
        {
        throw new UnsupportedOperationException("Can't remove from a " + this.getClass().getName());
        }

    // ------ data members --------------------------------------------------

    /**
     * The underlying {@link Map} entry {@link Iterator}.
     */
    private Iterator> m_iterMap;
    }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy