Package org.assertj.core.api
Class ComparatorFactory
- java.lang.Object
-
- org.assertj.core.api.ComparatorFactory
-
public class ComparatorFactory extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static ComparatorFactory
INSTANCE
-
Constructor Summary
Constructors Constructor Description ComparatorFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static <T extends java.lang.Number>
java.math.BigDecimalasBigDecimal(T number)
Convert to a precise BigDecimal object using an intermediate String.java.util.Comparator<java.lang.Double>
doubleComparatorWithPrecision(double precision)
java.util.Comparator<java.lang.Float>
floatComparatorWithPrecision(float precision)
private static <T extends java.lang.Number>
booleanisWithinPrecision(T actual, T expected, T precision)
Returns true if the abs(expected - precision) is <= precision, false otherwise.
-
-
-
Field Detail
-
INSTANCE
public static final ComparatorFactory INSTANCE
-
-
Method Detail
-
doubleComparatorWithPrecision
public java.util.Comparator<java.lang.Double> doubleComparatorWithPrecision(double precision)
-
floatComparatorWithPrecision
public java.util.Comparator<java.lang.Float> floatComparatorWithPrecision(float precision)
-
asBigDecimal
private static <T extends java.lang.Number> java.math.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 java.lang.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 valueexpected
- the expected valueprecision
- the acceptable precision- Returns:
- whether true if the abs(expected - precision) is <= precision, false otherwise.
-
-