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

net.sf.javagimmicks.util.ComparableComparator Maven / Gradle / Ivy

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

import java.io.Serializable;
import java.util.Comparator;

/**
 * A {@link Comparator} implementation the simply compares {@link Comparable}
 * objects - useful in cases where an API has the explicit need for a
 * {@link Comparator} implementation.
 * 
 * @param 
 *           the type of {@link Comparable}s to compare
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public final class ComparableComparator> implements Comparator, Serializable
{
   private static final long serialVersionUID = 1790088535783496697L;

   static
   {
      INSTANCE = new ComparableComparator();
   }

   /**
    * @deprecated Use static method {@link #getInstance()} instead.
    */
   @Deprecated
   public ComparableComparator()
   {

   }

   /**
    * The static singleton instance of {@link ComparableComparator}.
    */
   public static ComparableComparator> INSTANCE;

   /**
    * Returns the singleton {@link Comparable} instance.
    * 
    * @param 
    *           the type of objects to compare
    * 
    * @return the singleton {@link Comparable} instance
    */
   public static final > ComparableComparator getInstance()
   {
      return (ComparableComparator) INSTANCE;
   }

   @Override
   public int compare(final T o1, final T o2)
   {
      return o1.compareTo(o2);
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy