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

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

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

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

import net.sf.javagimmicks.collections8.RingCursor;
import net.sf.javagimmicks.transform8.Transforming;

class TransformingRingCursor
   implements Transforming, RingCursor
{
   protected final RingCursor _internalRingCursor;
   private final Function _transformer;
   
   TransformingRingCursor(RingCursor ringCursor, Function transformer)
   {
      _internalRingCursor = ringCursor;
      _transformer = transformer;
   }
   
   public Function getTransformerFunction()
   {
      return _transformer;
   }
   
   public int size()
   {
      return _internalRingCursor.size();
   }

   public T get()
   {
      return getTransformerFunction().apply(_internalRingCursor.get());
   }

   public void insertAfter(T value)
   {
      throw new UnsupportedOperationException();
   }

   public void insertBefore(T value)
   {
      throw new UnsupportedOperationException();
   }

   public T next()
   {
      return getTransformerFunction().apply(_internalRingCursor.next());
   }

   public T previous()
   {
      return getTransformerFunction().apply(_internalRingCursor.previous());
   }

   public T remove()
   {
      return getTransformerFunction().apply(_internalRingCursor.remove());
   }

   public RingCursor cursor()
   {
      return TransformerUtils.decorate(_internalRingCursor.cursor(), getTransformerFunction());
   }

   public Iterator iterator()
   {
      return TransformerUtils.decorate(_internalRingCursor.iterator(), getTransformerFunction());
   }

   public Spliterator spliterator()
   {
      return TransformerUtils.decorate(_internalRingCursor.spliterator(), getTransformerFunction());
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy