Package org.hamcrest.comparator
Class ComparatorMatcherBuilder<T>
java.lang.Object
org.hamcrest.comparator.ComparatorMatcherBuilder<T>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ComparatorMatcherBuilder
(Comparator<T> comparator, boolean includeComparatorInDescription) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ComparatorMatcherBuilder<T>
comparedBy
(Comparator<T> comparator) Creates a matcher factory for matchers ofComparators
s ofT
.comparesEqualTo
(T value) Creates a matcher ofT
object that matches when the examined object is equal to the specified value, as reported by theComparator
used to create this builder.greaterThan
(T value) Creates a matcher ofT
object that matches when the examined object is greater than the specified value, as reported by theComparator
used to create this builder.greaterThanOrEqualTo
(T value) Creates a matcher ofT
object that matches when the examined object is greater than or equal to the specified value, as reported by theComparator
used to create this builder.Creates a matcher ofT
object that matches when the examined object is less than the specified value, as reported by theComparator
used to create this builder.lessThanOrEqualTo
(T value) Creates a matcher ofT
object that matches when the examined object is less than or equal to the specified value, as reported by theComparator
used to create this builder.static <T extends Comparable<T>>
ComparatorMatcherBuilder<T>Creates a matcher factory for matchers ofComparable
s.
-
Field Details
-
comparator
-
includeComparatorInDescription
private final boolean includeComparatorInDescription
-
-
Constructor Details
-
ComparatorMatcherBuilder
-
-
Method Details
-
usingNaturalOrdering
Creates a matcher factory for matchers ofComparable
s. For example:assertThat(1, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().lessThanOrEqualTo(1))
-
comparedBy
Creates a matcher factory for matchers ofComparators
s ofT
. For example:assertThat(5, comparedBy(new Comparator<Integer>() { public int compare(Integer o1, Integer o2) { return -o1.compareTo(o2); } }).lessThan(4))
-
comparesEqualTo
Creates a matcher ofT
object that matches when the examined object is equal to the specified value, as reported by theComparator
used to create this builder. For example:assertThat(1, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().comparesEqualTo(1))
- Parameters:
value
- the value which, when passed to the Comparator supplied to this builder, should return zero
-
greaterThan
Creates a matcher ofT
object that matches when the examined object is greater than the specified value, as reported by theComparator
used to create this builder. For example:assertThat(2, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().greaterThan(1))
- Parameters:
value
- the value which, when passed to the Comparator supplied to this builder, should return greater than zero
-
greaterThanOrEqualTo
Creates a matcher ofT
object that matches when the examined object is greater than or equal to the specified value, as reported by theComparator
used to create this builder. For example:assertThat(1, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().greaterThanOrEqualTo(1))
- Parameters:
value
- the value which, when passed to the Comparator supplied to this builder, should return greater than or equal to zero
-
lessThan
Creates a matcher ofT
object that matches when the examined object is less than the specified value, as reported by theComparator
used to create this builder. For example:assertThat(1, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().lessThan(2))
- Parameters:
value
- the value which, when passed to the Comparator supplied to this builder, should return less than zero
-
lessThanOrEqualTo
Creates a matcher ofT
object that matches when the examined object is less than or equal to the specified value, as reported by theComparator
used to create this builder. For example:assertThat(1, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().lessThanOrEqualTo(1))
- Parameters:
value
- the value which, when passed to the Comparator supplied to this builder, should return less than or equal to zero
-