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

net.sf.javagimmicks.collections8.transformer.TransformingSpliterator Maven / Gradle / Ivy

There is a newer version: 0.99-alpha1
Show newest version
package net.sf.javagimmicks.collections8.transformer;

import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.Function;

import net.sf.javagimmicks.transform8.Transforming;

class TransformingSpliterator implements Transforming, Spliterator
{
   protected final Spliterator _internalSpliterator;
   private final Function _transformer;

   TransformingSpliterator(final Spliterator internalSpliterator, final Function transformer)
   {
      _internalSpliterator = internalSpliterator;
      _transformer = transformer;
   }

   @Override
   public boolean tryAdvance(final Consumer action)
   {
      return _internalSpliterator.tryAdvance(TransformerUtils.decorate(action, getTransformerFunction()));
   }

   @Override
   public Spliterator trySplit()
   {
      final Spliterator split = _internalSpliterator.trySplit();

      return split != null ? TransformerUtils.decorate(split, getTransformerFunction()) : null;
   }

   @Override
   public long estimateSize()
   {
      return _internalSpliterator.estimateSize();
   }

   @Override
   public int characteristics()
   {
      return _internalSpliterator.characteristics();
   }

   @Override
   public Function getTransformerFunction()
   {
      return _transformer;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy