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

org.infinispan.cli.util.TransformingIterator Maven / Gradle / Ivy

package org.infinispan.cli.util;

import java.util.Iterator;
import java.util.function.Function;

/**
 * @since 14.0
 **/
public class TransformingIterator implements Iterator {
   private final Iterator iterator;
   private final Function transformer;

   public TransformingIterator(Iterator iterator, Function transformer) {
      this.iterator = iterator;
      this.transformer = transformer;
   }

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

   @Override
   public T next() {
      return transformer.apply(iterator.next());
   }
}