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

org.infinispan.stream.impl.RemovableCloseableIterator Maven / Gradle / Ivy

package org.infinispan.stream.impl;

import org.infinispan.Cache;
import org.infinispan.commons.util.CloseableIterator;

import java.util.function.Function;

/**
 * A CloseableIterator implementation that allows for a CloseableIterator that doesn't allow remove operations to
 * implement remove by delegating the call to the provided cache to remove the previously read value.  The key used
 * to remove from the cache is determined by first applying the removeFunction to the value retrieved from the
 * iterator.
 *
 * @author wburns
 * @since 8.0
 */
public class RemovableCloseableIterator extends RemovableIterator implements CloseableIterator {
   protected final CloseableIterator realIterator;

   public RemovableCloseableIterator(CloseableIterator realIterator, Cache cache,
           Function removeFunction) {
      super(realIterator, cache, removeFunction);
      this.realIterator = realIterator;
   }

   @Override
   public void close() {
      currentValue = null;
      previousValue = null;
      realIterator.close();
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy