All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hamcrest.number.OrderingComparison Maven / Gradle / Ivy

There is a newer version: 3.0
Show newest version
package org.hamcrest.number;

import org.hamcrest.Matcher;
import org.hamcrest.comparator.ComparatorMatcherBuilder;

public class OrderingComparison {

    private OrderingComparison() {
    }

    /**
     * Creates a matcher of {@link 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))
* * @param * the matcher type. * @param value the value which, when passed to the compareTo method of the examined object, should return zero * @return The matcher. */ public static > Matcher comparesEqualTo(T value) { return ComparatorMatcherBuilder.usingNaturalOrdering().comparesEqualTo(value); } /** * Creates a matcher of {@link 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))
* * @param * the matcher type. * @param value the value which, when passed to the compareTo method of the examined object, should return greater * than zero * @return The matcher. */ public static > Matcher greaterThan(T value) { return ComparatorMatcherBuilder.usingNaturalOrdering().greaterThan(value); } /** * Creates a matcher of {@link 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))
* * @param * the matcher type. * @param value the value which, when passed to the compareTo method of the examined object, should return greater * than or equal to zero * @return The matcher. */ public static > Matcher greaterThanOrEqualTo(T value) { return ComparatorMatcherBuilder.usingNaturalOrdering().greaterThanOrEqualTo(value); } /** * Creates a matcher of {@link 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))
* * @param * the matcher type. * @param value the value which, when passed to the compareTo method of the examined object, should return less * than zero * @return The matcher. */ public static > Matcher lessThan(T value) { return ComparatorMatcherBuilder.usingNaturalOrdering().lessThan(value); } /** * Creates a matcher of {@link 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))
* * @param * the matcher type. * @param value the value which, when passed to the compareTo method of the examined object, should return less * than or equal to zero * @return The matcher. */ public static > Matcher lessThanOrEqualTo(T value) { return ComparatorMatcherBuilder.usingNaturalOrdering().lessThanOrEqualTo(value); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy