Class CompareHelper

java.lang.Object
com.peterphi.std.types.CompareHelper

public class CompareHelper extends Object
Makes the use of Java's ugly compareTo operation a little more readable
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    eq(int result)
    Evaluates the result of a.compareTo(b) and returns a == b
    static <T> boolean
    eq(Comparable<T> a, T b)
    a == b
    static boolean
    ge(int result)
    Evaluates the result of a.compareTo(b) and returns a >= b
    static <T> boolean
    ge(Comparable<T> a, T b)
    a >= b
    static boolean
    gt(int result)
    Evaluates the result of a.compareTo(b) and returns a > b
    static <T> boolean
    gt(Comparable<T> a, T b)
    a > b
    static boolean
    le(int result)
    Evaluates the result of a.compareTo(b) and returns a <= b
    static <T> boolean
    le(Comparable<T> a, T b)
    a <= b
    static boolean
    lt(int result)
    Evaluates the result of a.compareTo(b) and returns a < b
    static <T> boolean
    lt(Comparable<T> a, T b)
    a < b

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CompareHelper

      public CompareHelper()
  • Method Details

    • lt

      public static boolean lt(int result)
      Evaluates the result of a.compareTo(b) and returns a < b
      Parameters:
      result -
      Returns:
    • eq

      public static boolean eq(int result)
      Evaluates the result of a.compareTo(b) and returns a == b
      Parameters:
      result -
      Returns:
    • le

      public static boolean le(int result)
      Evaluates the result of a.compareTo(b) and returns a <= b
      Parameters:
      result -
      Returns:
    • gt

      public static boolean gt(int result)
      Evaluates the result of a.compareTo(b) and returns a > b
      Parameters:
      result -
      Returns:
    • ge

      public static boolean ge(int result)
      Evaluates the result of a.compareTo(b) and returns a >= b
      Parameters:
      result -
      Returns:
    • lt

      public static <T> boolean lt(Comparable<T> a, T b)
      a < b
      Type Parameters:
      T -
      Parameters:
      a -
      b -
      Returns:
      true if a < b
    • le

      public static <T> boolean le(Comparable<T> a, T b)
      a <= b
      Type Parameters:
      T -
      Parameters:
      a -
      b -
      Returns:
      true if a <= b
    • gt

      public static <T> boolean gt(Comparable<T> a, T b)
      a > b
      Type Parameters:
      T -
      Parameters:
      a -
      b -
      Returns:
      true if a > b
    • ge

      public static <T> boolean ge(Comparable<T> a, T b)
      a >= b
      Type Parameters:
      T -
      Parameters:
      a -
      b -
      Returns:
      true if a >= b
    • eq

      public static <T> boolean eq(Comparable<T> a, T b)
      a == b
      Type Parameters:
      T -
      Parameters:
      a -
      b -
      Returns: