Top Description Fields Constructors Methods
org.assertj.core.internal

public abstract Class Numbers<NUMBER extends Number & Comparable<NUMBER>>

extends Comparables
Class Inheritance
Known Direct Subclasses
org.assertj.core.internal.RealNumbers, org.assertj.core.internal.Shorts, org.assertj.core.internal.BigDecimals, org.assertj.core.internal.BigIntegers, org.assertj.core.internal.Bytes, org.assertj.core.internal.Integers, org.assertj.core.internal.Longs
Static Imports
java.lang.Math.abs, org.assertj.core.error.ShouldBeEqualWithinOffset.shouldBeEqual, .ShouldBeEqualWithinPercentage.shouldBeEqualWithinPercentage, .ShouldNotBeEqualWithinOffset.shouldNotBeEqual, .ShouldNotBeEqualWithinPercentage.shouldNotBeEqualWithinPercentage, org.assertj.core.internal.CommonValidations.checkNumberIsNotNull, .CommonValidations.checkOffsetIsNotNull, .CommonValidations.checkPercentageIsNotNull

Base class of reusable assertions for numbers.
Authors
Drummond Dawson, Joel Costigliola, Nicolas François

Field Summary

Inherited from org.assertj.core.internal.Comparables:
failures

Constructor Summary

AccessConstructor and Description
public
public
Numbers(ComparisonStrategy comparisonStrategy)

Method Summary

Modifier and TypeMethod and Description
protected abstract NUMBER
absDiff(final NUMBER actual, final NUMBER other)

protected boolean
areEqual(final NUMBER value, final NUMBER other)

Overrides org.assertj.core.internal.Comparables.areEqual.

public void
assertIsBetween(AssertionInfo
contains information about the assertion.
info
,
NUMBER
the actual value.
actual
,
NUMBER
range start value
start
,
NUMBER
range end value
end
)

Asserts that the actual value is in [start, end] range (start included, end included).

public void
assertIsCloseTo(final AssertionInfo
contains information about the assertion.
info
,
final NUMBER
the actual value.
actual
,
final NUMBER
the value to compare actual too.
expected
,
final Offset<NUMBER>
the given positive offset.
offset
)

Asserts that the actual value is close to the expected one by less than the given offset.

public void
assertIsCloseToPercentage(final AssertionInfo
contains information about the assertion.
info
,
final NUMBER
the actual value.
actual
,
final NUMBER
the expected value.
other
,
final Percentage
the given positive percentage.
percentage
)

Asserts that the actual value is close to the an offset expressed as an percentage value.

public void
assertIsNegative(AssertionInfo
contains information about the assertion.
info
,
NUMBER
the actual value.
actual
)

Asserts that the actual value is negative.

public void
assertIsNotCloseTo(final AssertionInfo
contains information about the assertion.
info
,
final NUMBER
the actual value.
actual
,
final NUMBER
the value to compare actual too.
expected
,
final Offset<NUMBER>
the given positive offset.
offset
)

Asserts that the actual value is not close to the expected one by less than the given offset.

public void
assertIsNotCloseToPercentage(final AssertionInfo
contains information about the assertion.
info
,
final NUMBER
the actual value.
actual
,
final NUMBER
the expected value.
other
,
final Percentage
the given positive percentage.
percentage
)

Asserts that the actual value is not close to the an offset expressed as an percentage value.

public void
assertIsNotNegative(AssertionInfo
contains information about the assertion.
info
,
NUMBER
the actual value.
actual
)

Asserts that the actual value is not negative.

public void
assertIsNotPositive(AssertionInfo
contains information about the assertion.
info
,
NUMBER
the actual value.
actual
)

Asserts that the actual value is not positive.

public void
assertIsNotZero(AssertionInfo
contains information about the assertion.
info
,
NUMBER
the actual value.
actual
)

Asserts that the actual value is not equal to zero.

public void
assertIsOne(AssertionInfo
contains information about the assertion.
info
,
NUMBER
the actual value.
actual
)

Asserts that the actual value is equal to one.

public void
assertIsPositive(AssertionInfo
contains information about the assertion.
info
,
NUMBER
the actual value.
actual
)

Asserts that the actual value is positive.

public void
assertIsStrictlyBetween(AssertionInfo
contains information about the assertion.
info
,
NUMBER
the actual value.
actual
,
NUMBER
the start value (exclusive), expected not to be null.
start
,
NUMBER
the end value (exclusive), expected not to be null.
end
)

Asserts that the actual value is in ]start, end[ range (start excluded, end excluded).

public void
assertIsZero(AssertionInfo
contains information about the assertion.
info
,
NUMBER
the actual value.
actual
)

Asserts that the actual value is equal to zero.

protected abstract boolean
isGreaterThan(final NUMBER value, final NUMBER other)

protected boolean
isGreaterThanOrEqualTo(final NUMBER value, final NUMBER other)

protected abstract NUMBER
one()

protected abstract NUMBER
zero()

Inherited from org.assertj.core.internal.Comparables:
assertEqualassertEqualByComparisonassertGreaterThanassertGreaterThanOrEqualToassertIsAfterassertIsAfterOrEqualToassertIsBeforeassertIsBeforeOrEqualToassertIsBetweenassertLessThanassertLessThanOrEqualToassertNotEqualassertNotEqualByComparisonassertNotNullequalsgetComparatorhashCoderesetFailuressetFailurestoString

Constructor Detail

Numbersback to summary
public Numbers()
Numbersback to summary
public Numbers(ComparisonStrategy comparisonStrategy)

Method Detail

absDiffback to summary
protected abstract NUMBER absDiff(final NUMBER actual, final NUMBER other)
areEqualback to summary
protected boolean areEqual(final NUMBER value, final NUMBER other)

Overrides org.assertj.core.internal.Comparables.areEqual.

assertIsBetweenback to summary
public void assertIsBetween(AssertionInfo info, NUMBER actual, NUMBER start, NUMBER end)

Asserts that the actual value is in [start, end] range (start included, end included).

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

start:NUMBER

range start value

end:NUMBER

range end value

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is positive.
  • if the actual value is not in [start, end] range.
NullPointerException:
  • if start value is null.
  • if end value is null.
assertIsCloseToback to summary
public void assertIsCloseTo(final AssertionInfo info, final NUMBER actual, final NUMBER expected, final Offset<NUMBER> offset)

Asserts that the actual value is close to the expected one by less than the given offset.

It does not rely on the custom comparisonStrategy (if one is set) because using an offset is already a specific comparison strategy.

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

expected:NUMBER

the value to compare actual too.

offset:Offset<NUMBER>

the given positive offset.

assertIsCloseToPercentageback to summary
public void assertIsCloseToPercentage(final AssertionInfo info, final NUMBER actual, final NUMBER other, final Percentage percentage)

Asserts that the actual value is close to the an offset expressed as an percentage value.

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

other:NUMBER

the expected value.

percentage:Percentage

the given positive percentage.

assertIsNegativeback to summary
public void assertIsNegative(AssertionInfo info, NUMBER actual)

Asserts that the actual value is negative.

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is not negative: it is either equal to or greater than zero.
assertIsNotCloseToback to summary
public void assertIsNotCloseTo(final AssertionInfo info, final NUMBER actual, final NUMBER expected, final Offset<NUMBER> offset)

Asserts that the actual value is not close to the expected one by less than the given offset.

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

expected:NUMBER

the value to compare actual too.

offset:Offset<NUMBER>

the given positive offset.

assertIsNotCloseToPercentageback to summary
public void assertIsNotCloseToPercentage(final AssertionInfo info, final NUMBER actual, final NUMBER other, final Percentage percentage)

Asserts that the actual value is not close to the an offset expressed as an percentage value.

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

other:NUMBER

the expected value.

percentage:Percentage

the given positive percentage.

assertIsNotNegativeback to summary
public void assertIsNotNegative(AssertionInfo info, NUMBER actual)

Asserts that the actual value is not negative.

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is negative.
assertIsNotPositiveback to summary
public void assertIsNotPositive(AssertionInfo info, NUMBER actual)

Asserts that the actual value is not positive.

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is positive.
assertIsNotZeroback to summary
public void assertIsNotZero(AssertionInfo info, NUMBER actual)

Asserts that the actual value is not equal to zero.
It does not rely on the custom comparisonStrategy (if one is set).

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is equal to zero.
assertIsOneback to summary
public void assertIsOne(AssertionInfo info, NUMBER actual)

Asserts that the actual value is equal to one.
It does not rely on the custom comparisonStrategy (if one is set).

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is not equal to one.
assertIsPositiveback to summary
public void assertIsPositive(AssertionInfo info, NUMBER actual)

Asserts that the actual value is positive.

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is not positive: it is either equal to or less than zero.
assertIsStrictlyBetweenback to summary
public void assertIsStrictlyBetween(AssertionInfo info, NUMBER actual, NUMBER start, NUMBER end)

Asserts that the actual value is in ]start, end[ range (start excluded, end excluded).

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

start:NUMBER

the start value (exclusive), expected not to be null.

end:NUMBER

the end value (exclusive), expected not to be null.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is not in ]start, end[ range.
NullPointerException:
  • if start value is null.
  • if end value is null.
assertIsZeroback to summary
public void assertIsZero(AssertionInfo info, NUMBER actual)

Asserts that the actual value is equal to zero.
It does not rely on the custom comparisonStrategy (if one is set).

Parameters
info:AssertionInfo

contains information about the assertion.

actual:NUMBER

the actual value.

Exceptions
AssertionError:
  • if the actual value is null.
  • if the actual value is not equal to zero.
isGreaterThanback to summary
protected abstract boolean isGreaterThan(final NUMBER value, final NUMBER other)
isGreaterThanOrEqualToback to summary
protected boolean isGreaterThanOrEqualTo(final NUMBER value, final NUMBER other)
oneback to summary
protected abstract NUMBER one()
zeroback to summary
protected abstract NUMBER zero()