Top Fields Constructors Methods
org.hamcrest.number

public Class OrderingComparison<T extends Comparable<T>>

extends TypeSafeMatcher<T extends Comparable<T>>
Class Inheritance
Imports
org.hamcrest.Description, .Factory, .Matcher, .TypeSafeMatcher

Field Summary

Modifier and TypeField and Description
private static final String[]
private static final int
private final T
private static final int
private static final int
private final int
private final int

Constructor Summary

AccessConstructor and Description
private
OrderingComparison(T expected, int minCompare, int maxCompare)

Method Summary

Modifier and TypeMethod and Description
private static String
asText(int comparison)

public static <T extends Comparable<T>> Matcher<T>
comparesEqualTo(T
the value which, when passed to the compareTo method of the examined object, should return zero
value
)

Creates a matcher of Comparable object that matches when the examined object is equal to the specified value, as reported by the compareTo method of the examined object.

public void
describeMismatchSafely(T actual, 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 static <T extends Comparable<T>> Matcher<T>
greaterThan(T
the value which, when passed to the compareTo method of the examined object, should return greater than zero
value
)

Creates a matcher of Comparable object that matches when the examined object is greater than the specified value, as reported by the compareTo method of the examined object.

public static <T extends Comparable<T>> Matcher<T>
greaterThanOrEqualTo(T
the value which, when passed to the compareTo method of the examined object, should return greater than or equal to zero
value
)

Creates a matcher of Comparable object that matches when the examined object is greater than or equal to the specified value, as reported by the compareTo method of the examined object.

public static <T extends Comparable<T>> Matcher<T>
lessThan(T
the value which, when passed to the compareTo method of the examined object, should return less than zero
value
)

Creates a matcher of Comparable object that matches when the examined object is less than the specified value, as reported by the compareTo method of the examined object.

public static <T extends Comparable<T>> Matcher<T>
lessThanOrEqualTo(T
the value which, when passed to the compareTo method of the examined object, should return less than or equal to zero
value
)

Creates a matcher of Comparable object that matches when the examined object is less than or equal to the specified value, as reported by the compareTo method of the examined object.

public boolean
matchesSafely(T actual)

Implements abstract org.hamcrest.TypeSafeMatcher.matchesSafely.

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

Field Detail

comparisonDescriptionsback to summary
private static final String[] comparisonDescriptions
EQUALback to summary
private static final int EQUAL
expectedback to summary
private final T expected
GREATER_THANback to summary
private static final int GREATER_THAN
LESS_THANback to summary
private static final int LESS_THAN
maxCompareback to summary
private final int maxCompare
minCompareback to summary
private final int minCompare

Constructor Detail

OrderingComparisonback to summary
private OrderingComparison(T expected, int minCompare, int maxCompare)

Method Detail

asTextback to summary
private static String asText(int comparison)
comparesEqualToback to summary
public static <T extends Comparable<T>> Matcher<T> comparesEqualTo(T value)

Creates a matcher of Comparable object that matches when the examined object is equal to the specified value, as reported by the compareTo method of the examined object.

For example:

assertThat(1, comparesEqualTo(1))
Parameters
value:T

the value which, when passed to the compareTo method of the examined object, should return zero

Annotations
@Factory
describeMismatchSafelyback to summary
public void describeMismatchSafely(T actual, 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
greaterThanback to summary
public static <T extends Comparable<T>> Matcher<T> greaterThan(T value)

Creates a matcher of Comparable object that matches when the examined object is greater than the specified value, as reported by the compareTo method of the examined object.

For example:

assertThat(2, greaterThan(1))
Parameters
value:T

the value which, when passed to the compareTo method of the examined object, should return greater than zero

Annotations
@Factory
greaterThanOrEqualToback to summary
public static <T extends Comparable<T>> Matcher<T> greaterThanOrEqualTo(T value)

Creates a matcher of Comparable object that matches when the examined object is greater than or equal to the specified value, as reported by the compareTo method of the examined object.

For example:

assertThat(1, greaterThanOrEqualTo(1))
Parameters
value:T

the value which, when passed to the compareTo method of the examined object, should return greater than or equal to zero

Annotations
@Factory
lessThanback to summary
public static <T extends Comparable<T>> Matcher<T> lessThan(T value)

Creates a matcher of Comparable object that matches when the examined object is less than the specified value, as reported by the compareTo method of the examined object.

For example:

assertThat(1, lessThan(2))
Parameters
value:T

the value which, when passed to the compareTo method of the examined object, should return less than zero

Annotations
@Factory
lessThanOrEqualToback to summary
public static <T extends Comparable<T>> Matcher<T> lessThanOrEqualTo(T value)

Creates a matcher of Comparable object that matches when the examined object is less than or equal to the specified value, as reported by the compareTo method of the examined object.

For example:

assertThat(1, lessThanOrEqualTo(1))
Parameters
value:T

the value which, when passed to the compareTo method of the examined object, should return less than or equal to zero

Annotations
@Factory
matchesSafelyback to summary
public boolean matchesSafely(T actual)

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