Class ComparatorFactory

java.lang.Object
org.assertj.core.api.ComparatorFactory

public class ComparatorFactory extends Object
  • Field Details

  • Constructor Details

    • ComparatorFactory

      public ComparatorFactory()
  • Method Details

    • doubleComparatorWithPrecision

      public Comparator<Double> doubleComparatorWithPrecision(double precision)
    • floatComparatorWithPrecision

      public Comparator<Float> floatComparatorWithPrecision(float precision)
    • asBigDecimal

      private static <T extends Number> BigDecimal asBigDecimal(T number)
      Convert to a precise BigDecimal object using an intermediate String.
      Type Parameters:
      T - type of expected and precision, which should be the subclass of java.lang.Number and java.lang.Comparable
      Parameters:
      number - the Number to convert
      Returns:
      the built BigDecimal
    • isWithinPrecision

      private static <T extends Number> boolean isWithinPrecision(T actual, T expected, T precision)
      Returns true if the abs(expected - precision) is <= precision, false otherwise.
      Type Parameters:
      T - type of number to compare including the precision
      Parameters:
      actual - the actual value
      expected - the expected value
      precision - the acceptable precision
      Returns:
      whether true if the abs(expected - precision) is <= precision, false otherwise.