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

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

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

import java.util.NavigableMap;
import java.util.NavigableSet;

import net.sf.javagimmicks.transform.BidiFunction;

class KeyBidiTransformingNavigableMap
   extends KeyBidiTransformingSortedMap
   implements NavigableMap
{
   /**
    * @deprecated Use TranformerUtils.decorateKeyBased() instead
    */
   @Deprecated
   public KeyBidiTransformingNavigableMap(NavigableMap map, BidiFunction transformer)
   {
      super(map, transformer);
   }

   public Entry ceilingEntry(KT key)
   {
      Entry ceilingEntry = getNavigableMap().ceilingEntry(transformBack(key));
      
      return ceilingEntry == null ? null : new KeyBidiTransformingEntry(
         ceilingEntry,
         getTransformerBidiFunction());
   }

   public KT ceilingKey(KT key)
   {
      KF ceilingKey = getNavigableMap().ceilingKey(transformBack(key));
      
      return ceilingKey != null ? transform(ceilingKey) : null;
   }

   public NavigableSet descendingKeySet()
   {
      return TransformerUtils.decorate(
         getNavigableMap().descendingKeySet(),
         getTransformerBidiFunction());
   }

   public NavigableMap descendingMap()
   {
      return TransformerUtils.decorateKeyBased(
         getNavigableMap().descendingMap(),
         getTransformerBidiFunction());
   }

   public Entry firstEntry()
   {
      Entry firstEntry = getNavigableMap().firstEntry();
      
      return firstEntry == null ? null : new KeyBidiTransformingEntry(
         firstEntry,
         getTransformerBidiFunction());
   }

   public Entry floorEntry(KT key)
   {
      Entry floorEntry = getNavigableMap().floorEntry(transformBack(key));
      
      return floorEntry == null ? null : new KeyBidiTransformingEntry(
         floorEntry,
         getTransformerBidiFunction());
   }

   public KT floorKey(KT key)
   {
      KF floorKey = getNavigableMap().floorKey(transformBack(key));
      
      return floorKey != null ? transform(floorKey) : null;
   }

   public NavigableMap headMap(KT toKey, boolean inclusive)
   {
      return TransformerUtils.decorateKeyBased(
         getNavigableMap().headMap(transformBack(toKey), inclusive),
         getTransformerBidiFunction());
   }

   public Entry higherEntry(KT key)
   {
      Entry higherEntry = getNavigableMap().higherEntry(transformBack(key));
      
      return higherEntry == null ? null : new KeyBidiTransformingEntry(
         higherEntry,
         getTransformerBidiFunction());
   }

   public KT higherKey(KT key)
   {
      KF higherKey = getNavigableMap().higherKey(transformBack(key));
      
      return higherKey != null ? transform(higherKey) : null;
   }

   public Entry lastEntry()
   {
      Entry lastEntry = getNavigableMap().lastEntry();
      
      return lastEntry == null ? null : new KeyBidiTransformingEntry(
         lastEntry,
         getTransformerBidiFunction());
   }

   public Entry lowerEntry(KT key)
   {
      Entry lowerEntry = getNavigableMap().lowerEntry(transformBack(key));
      
      return lowerEntry == null ? null : new KeyBidiTransformingEntry(
         lowerEntry,
         getTransformerBidiFunction());
   }

   public KT lowerKey(KT key)
   {
      KF lowerKey = getNavigableMap().lowerKey(transformBack(key));
      
      return lowerKey != null ? transform(lowerKey) : null;
   }

   public NavigableSet navigableKeySet()
   {
      return TransformerUtils.decorate(
         getNavigableMap().navigableKeySet(),
         getTransformerBidiFunction());
   }

   public Entry pollFirstEntry()
   {
      Entry firstEntry = getNavigableMap().pollFirstEntry();
      
      return firstEntry == null ? null : new KeyBidiTransformingEntry(
         firstEntry,
         getTransformerBidiFunction());
   }

   public Entry pollLastEntry()
   {
      Entry lastEntry = getNavigableMap().pollLastEntry();
      
      return lastEntry == null ? null : new KeyBidiTransformingEntry(
         lastEntry,
         getTransformerBidiFunction());
   }

   public NavigableMap subMap(KT fromKey, boolean fromInclusive,
         KT toKey, boolean toInclusive)
   {
      return TransformerUtils.decorateKeyBased(
         getNavigableMap().subMap(
            transformBack(fromKey),
            fromInclusive,
            transformBack(toKey),
            toInclusive),
         getTransformerBidiFunction());
   }

   public NavigableMap tailMap(KT fromKey, boolean inclusive)
   {
      return TransformerUtils.decorateKeyBased(
         getNavigableMap().tailMap(transformBack(fromKey), inclusive),
         getTransformerBidiFunction());
   }
   
   protected NavigableMap getNavigableMap()
   {
      return (NavigableMap)_internalMap;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy