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

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

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

import java.util.Comparator;
import java.util.function.Function;

import net.sf.javagimmicks.transform8.Transforming;

class TransformingComparator implements Comparator, Transforming
{
   protected final Comparator _internalComparator;
   private final Function _transformer;

   TransformingComparator(Comparator comparator, Function transformer)
   {
      _internalComparator = comparator;
      _transformer = transformer;
   }

   public int compare(T o1, T o2)
   {
      return _internalComparator.compare(_transformer.apply(o1), _transformer.apply(o2));
   }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy