Everything here can be @ReplacedBy something else.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2774 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray.j.greenwell
2010-04-16 00:55:42 +00:00
parent 0454f1cf84
commit 3ad9520cb0
@@ -22,6 +22,8 @@ package com.samskivert.util;
import java.util.Comparator;
import com.samskivert.annotation.ReplacedBy;
/**
* A repository for standard comparators.
*/
@@ -30,6 +32,7 @@ public class Comparators
/**
* A comparator that compares the toString() value of all objects case insensitively.
*/
@ReplacedBy("com.google.common.collect.Ordering.from(String.CASE_INSENSITIVE_ORDER).onResultOf(Functions.toStringFunction()")
public static final Comparator<Object> LEXICAL_CASE_INSENSITIVE = new Comparator<Object>() {
public int compare (Object o1, Object o2)
{
@@ -49,6 +52,7 @@ public class Comparators
/**
* A comparator that compares {@link Comparable<Object>} instances.
*/
@ReplacedBy("com.google.common.collect.Ordering.natural().nullsLast()")
public static final Comparator<Comparable<Object>> COMPARABLE =
new Comparator<Comparable<Object>>() {
public int compare (Comparable<Object> o1, Comparable<Object> o2)
@@ -74,6 +78,7 @@ public class Comparators
*/
// we can't do the "more correct" <T extends Comparable<? super T>> here as that causes other
// code to freak out; I don't entirely understand why
@ReplacedBy("com.google.common.collect.Ordering.natural().nullsLast()")
public static final <T extends Comparable<?>> Comparator<T> comparable ()
{
@SuppressWarnings("unchecked") Comparator<T> comp = (Comparator<T>)COMPARABLE;
@@ -84,6 +89,7 @@ public class Comparators
* Compares two bytes, returning 1, 0, or -1.
* TODO: remove when Java finally has this method in Byte.
*/
@ReplacedBy("com.google.common.primitives.SignedBytes.compare()")
public static int compare (byte value1, byte value2)
{
return (value1 < value2 ? -1 : (value1 == value2 ? 0 : 1));
@@ -93,6 +99,7 @@ public class Comparators
* Compares two chars, returning 1, 0, or -1.
* TODO: remove when Java finally has this method in Character.
*/
@ReplacedBy("com.google.common.primitives.Chars.compare()")
public static int compare (char value1, char value2)
{
return (value1 < value2 ? -1 : (value1 == value2 ? 0 : 1));
@@ -102,6 +109,7 @@ public class Comparators
* Compares two shorts, returning 1, 0, or -1.
* TODO: remove when Java finally has this method in Character.
*/
@ReplacedBy("com.google.common.primitives.Shorts.compare()")
public static int compare (short value1, short value2)
{
return (value1 < value2 ? -1 : (value1 == value2 ? 0 : 1));
@@ -111,6 +119,7 @@ public class Comparators
* Compares two integers in an overflow safe manner, returning 1, 0, or -1.
* TODO: remove when Java finally has this method in Integer.
*/
@ReplacedBy("com.google.common.primitives.Ints.compare()")
public static int compare (int value1, int value2)
{
return (value1 < value2 ? -1 : (value1 == value2 ? 0 : 1));
@@ -120,6 +129,7 @@ public class Comparators
* Compares two longs in an overflow safe manner, returning 1, 0, or -1.
* TODO: remove when Java finally has this method in Long.
*/
@ReplacedBy("com.google.common.primitives.Longs.compare()")
public static int compare (long value1, long value2)
{
return (value1 < value2 ? -1 : (value1 == value2 ? 0 : 1));
@@ -133,6 +143,7 @@ public class Comparators
* </pre>
* If all values in the array are zero, zero is returned.
*/
@ReplacedBy("com.google.common.collect.ComparisonChain")
public static int combine (int ... values)
{
for (int value : values) {
@@ -151,6 +162,7 @@ public class Comparators
* Compares two booleans, returning 1, 0, or -1.
* TODO: remove when Java finally has this method in Boolean.
*/
@ReplacedBy("com.google.common.primitives.Booleans.compare()")
public static int compare (boolean value1, boolean value2)
{
return (value1 == value2) ? 0 : (value1 ? 1 : -1);