public final class ComparatorMatcherBuilder<T>
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T> ComparatorMatcherBuilder<T> |
comparedBy(java.util.Comparator<T> comparator)
Creates a matcher factory for matchers of
Comparators s of T . |
Matcher<T> |
comparesEqualTo(T value)
Creates a matcher of
T object that matches when the examined object is
equal to the specified value, as reported by the Comparator used to
create this builder. |
Matcher<T> |
greaterThan(T value)
Creates a matcher of
T object that matches when the examined object is
greater than the specified value, as reported by the Comparator used to
create this builder. |
Matcher<T> |
greaterThanOrEqualTo(T value)
Creates a matcher of
T object that matches when the examined object is
greater than or equal to the specified value, as reported by the Comparator used to
create this builder. |
Matcher<T> |
lessThan(T value)
Creates a matcher of
T object that matches when the examined object is
less than the specified value, as reported by the Comparator used to
create this builder. |
Matcher<T> |
lessThanOrEqualTo(T value)
Creates a matcher of
T object that matches when the examined object is
less than or equal to the specified value, as reported by the Comparator used to
create this builder. |
static <T extends java.lang.Comparable<T>> |
usingNaturalOrdering()
Creates a matcher factory for matchers of
Comparable s. |
public static <T extends java.lang.Comparable<T>> ComparatorMatcherBuilder<T> usingNaturalOrdering()
Comparable
s.
For example:
assertThat(1, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().lessThanOrEqualTo(1))
public static <T> ComparatorMatcherBuilder<T> comparedBy(java.util.Comparator<T> comparator)
Comparators
s of T
.
For example:
assertThat(5, comparedBy(new Comparator<Integer>() { public int compare(Integer o1, Integer o2) { return -o1.compareTo(o2); } }).lessThan(4))
public Matcher<T> comparesEqualTo(T value)
T
object that matches when the examined object is
equal to the specified value, as reported by the Comparator
used to
create this builder.
For example:
assertThat(1, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().comparesEqualTo(1))
value
- the value which, when passed to the Comparator supplied to this builder, should return zeropublic Matcher<T> greaterThan(T value)
T
object that matches when the examined object is
greater than the specified value, as reported by the Comparator
used to
create this builder.
For example:
assertThat(2, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().greaterThan(1))
value
- the value which, when passed to the Comparator supplied to this builder, should return greater
than zeropublic Matcher<T> greaterThanOrEqualTo(T value)
T
object that matches when the examined object is
greater than or equal to the specified value, as reported by the Comparator
used to
create this builder.
For example:
assertThat(1, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().greaterThanOrEqualTo(1))
value
- the value which, when passed to the Comparator supplied to this builder, should return greater
than or equal to zeropublic Matcher<T> lessThan(T value)
T
object that matches when the examined object is
less than the specified value, as reported by the Comparator
used to
create this builder.
For example:
assertThat(1, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().lessThan(2))
value
- the value which, when passed to the Comparator supplied to this builder, should return less
than zeropublic Matcher<T> lessThanOrEqualTo(T value)
T
object that matches when the examined object is
less than or equal to the specified value, as reported by the Comparator
used to
create this builder.
For example:
assertThat(1, ComparatorMatcherBuilder.<Integer>usingNaturalOrdering().lessThanOrEqualTo(1))
value
- the value which, when passed to the Comparator supplied to this builder, should return less
than or equal to zero