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

org.infinispan.commons.util.RemovableCloseableIterator Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev03
Show newest version
package org.infinispan.commons.util;

import java.util.function.Consumer;

/**
 * A CloseableIterator implementation that allows for a CloseableIterator that doesn't allow remove operations to
 * implement remove by delegating the call to the provided consumer to remove the previously read value.
 *
 * @author wburns
 * @since 9.1
 */
public class RemovableCloseableIterator extends RemovableIterator implements CloseableIterator {
   protected final CloseableIterator realIterator;

   public RemovableCloseableIterator(CloseableIterator realIterator, Consumer consumer) {
      super(realIterator, consumer);
      this.realIterator = realIterator;
   }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy