Class Comparables


  • public final class Comparables
    extends Object
    • Method Detail

      • compare

        public static int compare​(int x,
                                  int y)
        Compares two int values numerically.
        Parameters:
        x - The first int to compare
        y - The second int to compare
        Returns:
        the value 0 if x == y; a value less than 0 if x < y; and a value greater than 0 if x > y
        See Also:
        Integer.compare(int, int)
      • compare

        public static int compare​(byte x,
                                  byte y)
        Compares two byte values numerically.
        Parameters:
        x - The first byte to compare
        y - The second byte to compare
        Returns:
        the value 0 if x == y; a value less than 0 if x < y; and a value greater than 0 if x > y
        See Also:
        Byte.compare(byte, byte)
      • compare

        public static int compare​(short x,
                                  short y)
        Compares two short values numerically.
        Parameters:
        x - The first short to compare
        y - The second short to compare
        Returns:
        the value 0 if x == y; a value less than 0 if x < y; and a value greater than 0 if x > y
        See Also:
        Short.compare(short, short)
      • compare

        public static int compare​(char x,
                                  char y)
        Compares two char values numerically.
        Parameters:
        x - The first char to compare
        y - The second char to compare
        Returns:
        the value 0 if x == y; a value less than 0 if x < y; and a value greater than 0 if x > y
        See Also:
        Character.compare(char, char)
      • compare

        public static int compare​(long x,
                                  long y)
        Compares two long values numerically.
        Parameters:
        x - The first long to compare
        y - The second long to compare
        Returns:
        the value 0 if x == y; a value less than 0 if x < y; and a value greater than 0 if x > y
        See Also:
        Long.compare(long, long)
      • compare

        public static int compare​(boolean x,
                                  boolean y)
        Compares two boolean values.
        Parameters:
        x - The first boolean to compare
        y - The second boolean to compare
        Returns:
        the value 0 if x == y; a value less than 0 if !x && y; and a value greater than 0 if x && !y
        See Also:
        Boolean.compare(boolean, boolean)
      • compare

        public static int compare​(float x,
                                  float y)
        Compares two float values numerically.
        Parameters:
        x - The first float to compare
        y - The second float to compare
        Returns:
        the value 0 if x == y; a value less than 0 if x < y; and a value greater than 0 if x > y
        See Also:
        Float.compare(float, float)
      • compare

        public static int compare​(double x,
                                  double y)
        Compares two double values numerically.
        Parameters:
        x - The first double to compare
        y - The second double to compare
        Returns:
        the value 0 if x == y; a value less than 0 if x < y; and a value greater than 0 if x > y
        See Also:
        Double.compare(double, double)
      • compare

        public static <T extends Comparable<T>> int compare​(T x,
                                                            T y)
        Compares two values x and y. null values are considered less than all other values.
        Type Parameters:
        T - the comparable type
        Parameters:
        x - The first value to compare
        y - The second value to compare
        Returns:
        the value 0 if x == y; a value less than 0 if x < y; and a value greater than 0 if x > y
        See Also:
        Double.compare(double, double)
      • compareUnsignedByte

        public static int compareUnsignedByte​(byte x,
                                              byte y)
        Compares two byte values numerically, but handle the byte value as an unsigned byte.
        Parameters:
        x - The first byte to compare
        y - The second byte to compare
        Returns:
        the value 0 if x == y; a value less than 0 if x < y; and a value greater than 0 if x > y
        See Also:
        Byte.compare(byte, byte)
      • inheritance

        public static <T> com.google.common.collect.Ordering<T> inheritance()
      • version

        public static com.google.common.collect.Ordering<String> version()