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

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

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

import net.sf.javagimmicks.collections.AbstractRingCursor;
import net.sf.javagimmicks.collections.RingCursor;
import net.sf.javagimmicks.transform.Transforming;
import net.sf.javagimmicks.util.Function;

class TransformingRingCursor
   extends AbstractRingCursor
   implements Transforming
{
   protected final RingCursor _internalRingCursor;
   private final Function _transformer;
   
   /**
    * @deprecated Use TranformerUtils.decorate() instead
    */
   @Deprecated
   public 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());
   }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy