Top Fields Constructors Methods
org.hamcrest.number

public Class BigDecimalCloseTo

extends TypeSafeMatcher<BigDecimal>
Class Inheritance
Imports
org.hamcrest.Description, .Matcher, .TypeSafeMatcher, java.math.BigDecimal, .MathContext

Field Summary

Modifier and TypeField and Description
private final BigDecimal
private final BigDecimal

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private BigDecimal
public static Matcher<BigDecimal>
closeTo(BigDecimal
the expected value of matching BigDecimals
operand
,
BigDecimal
the delta (+/-) within which matches will be allowed
error
)

Creates a matcher of java.math.BigDecimals that matches when an examined BigDecimal is equal to the specified operand, within a range of +/- error.

public void
describeMismatchSafely(BigDecimal item, Description mismatchDescription)

Overrides org.hamcrest.TypeSafeMatcher.describeMismatchSafely.

Subclasses should override this.
public void
describeTo(Description
The description to be built or appended to.
description
)

Implements org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object.
public boolean
matchesSafely(BigDecimal item)

Implements abstract org.hamcrest.TypeSafeMatcher.matchesSafely.

Subclasses should implement this.
Inherited from org.hamcrest.TypeSafeMatcher:
describeMismatchmatches

Field Detail

deltaback to summary
private final BigDecimal delta
valueback to summary
private final BigDecimal value

Constructor Detail

BigDecimalCloseToback to summary
public BigDecimalCloseTo(BigDecimal value, BigDecimal error)

Method Detail

actualDeltaback to summary
private BigDecimal actualDelta(BigDecimal item)
closeToback to summary
public static Matcher<BigDecimal> closeTo(BigDecimal operand, BigDecimal error)

Creates a matcher of java.math.BigDecimals that matches when an examined BigDecimal is equal to the specified operand, within a range of +/- error. The comparison for equality is done by BigDecimals java.math.BigDecimal#compareTo(java.math.BigDecimal) method. For example:

assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))
Parameters
operand:BigDecimal

the expected value of matching BigDecimals

error:BigDecimal

the delta (+/-) within which matches will be allowed

describeMismatchSafelyback to summary
public void describeMismatchSafely(BigDecimal item, Description mismatchDescription)

Overrides org.hamcrest.TypeSafeMatcher.describeMismatchSafely.

Doc from org.hamcrest.TypeSafeMatcher.describeMismatchSafely.

Subclasses should override this. The item will already have been checked for the specific type and will never be null.

Annotations
@Override
describeToback to summary
public void describeTo(Description description)

Implements org.hamcrest.SelfDescribing.describeTo.

Doc from org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object. The description may be part of a a description of a larger object of which this is just a component, so it should be worded appropriately.

Parameters
description:Description

The description to be built or appended to.

Annotations
@Override
matchesSafelyback to summary
public boolean matchesSafely(BigDecimal item)

Implements abstract org.hamcrest.TypeSafeMatcher.matchesSafely.

Doc from org.hamcrest.TypeSafeMatcher.matchesSafely.

Subclasses should implement this. The item will already have been checked for the specific type and will never be null.

Annotations
@Override