Top Fields Constructors Methods
org.assertj.core.api

public Class ComparatorFactory

extends Object
Class Inheritance
Imports
java.math.BigDecimal, java.util.Comparator, org.assertj.core.internal.Doubles, .Floats

Field Summary

Modifier and TypeField and Description
public static final ComparatorFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static <
type of expected and precision, which should be the subclass of java.lang.Number and java.lang.Comparable
T extends Number
>
BigDecimal

Returns:

the built BigDecimal
asBigDecimal
(T
the Number to convert
number
)

Convert to a precise BigDecimal object using an intermediate String.

public Comparator<Double>
public Comparator<Float>
private static <
type of number to compare including the precision
T extends Number
>
boolean

Returns:

whether true if the abs(expected - precision) is <= precision, false otherwise.
isWithinPrecision
(T
the actual value
actual
,
T
the expected value
expected
,
T
the acceptable precision
precision
)

Returns true if the abs(expected - precision) is <= precision, false otherwise.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final ComparatorFactory INSTANCE

Constructor Detail

ComparatorFactoryback to summary
public ComparatorFactory()

Method Detail

asBigDecimalback to summary
private static <T extends Number> BigDecimal asBigDecimal(T number)

Convert to a precise BigDecimal object using an intermediate String.

Parameters
<T>
type of expected and precision, which should be the subclass of java.lang.Number and java.lang.Comparable
number:T

the Number to convert

Returns:BigDecimal

the built BigDecimal

doubleComparatorWithPrecisionback to summary
public Comparator<Double> doubleComparatorWithPrecision(double precision)
floatComparatorWithPrecisionback to summary
public Comparator<Float> floatComparatorWithPrecision(float precision)
isWithinPrecisionback to summary
private static <T extends Number> boolean isWithinPrecision(T actual, T expected, T precision)

Returns true if the abs(expected - precision) is <= precision, false otherwise.

Parameters
<T>
type of number to compare including the precision
actual:T

the actual value

expected:T

the expected value

precision:T

the acceptable precision

Returns:boolean

whether true if the abs(expected - precision) is <= precision, false otherwise.