net.sf.javagimmicks.util.ComparableComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gimmicks Show documentation
Show all versions of gimmicks Show documentation
Utility classes, APIs and tools for Java
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 extends Comparable>> 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