Skip to content

Commit b27ea1f

Browse files
committed
Merging changes from v7.0 branch to the new v2.x branch.
Deprecating OrderingComparison in favour of MatchingObjects.
1 parent f9ba174 commit b27ea1f

File tree

6 files changed

+40
-5
lines changed

6 files changed

+40
-5
lines changed

hamcrest-library/src/main/java/org/hamcrest/beans/HasProperty.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package org.hamcrest.beans;
44

55
import org.hamcrest.Description;
6+
import org.hamcrest.Matcher;
67
import org.hamcrest.TypeSafeMatcher;
78

89
/**
@@ -41,4 +42,12 @@ public void describeTo(Description description) {
4142
description.appendText("hasProperty(").appendValue(propertyName).appendText(")");
4243
}
4344

45+
/**
46+
* @deprecated use {@link org.hamcrest.beans.MatchingBeans#hasProperty(String)}
47+
*/
48+
@Deprecated
49+
public static <T> Matcher<T> hasProperty(String propertyName) {
50+
return new HasProperty<>(propertyName);
51+
}
52+
4453
}

hamcrest-library/src/main/java/org/hamcrest/beans/HasPropertyWithValue.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,11 @@ public Condition<Method> apply(PropertyDescriptor property, Description mismatch
133133
};
134134
}
135135

136+
/**
137+
* @deprecated use {@link org.hamcrest.beans.MatchingBeans#hasProperty(String, org.hamcrest.Matcher)}
138+
*/
139+
@Deprecated
140+
public static <T> Matcher<T> hasProperty(String propertyName, Matcher<?> valueMatcher) {
141+
return new HasPropertyWithValue<>(propertyName, valueMatcher);
142+
}
136143
}

hamcrest-library/src/main/java/org/hamcrest/beans/SamePropertyValuesAs.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,12 @@ private static Object readProperty(Method method, Object target) {
123123
}
124124
}
125125

126+
/**
127+
* @deprecated use {@link org.hamcrest.beans.MatchingBeans#samePropertyValuesAs(Object)}
128+
*/
129+
@Deprecated
130+
public static <T> Matcher<T> samePropertyValuesAs(T expectedBean) {
131+
return new SamePropertyValuesAs<>(expectedBean);
132+
}
133+
126134
}

hamcrest-library/src/main/java/org/hamcrest/number/IsCloseTo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package org.hamcrest.number;
44

55
import org.hamcrest.Description;
6+
import org.hamcrest.Matcher;
67
import org.hamcrest.TypeSafeMatcher;
78

89
import static java.lang.Math.abs;
@@ -46,4 +47,12 @@ public void describeTo(Description description) {
4647
private double actualDelta(Double item) {
4748
return abs(item - value) - delta;
4849
}
50+
51+
/**
52+
* @deprecated use {@link org.hamcrest.number.MatchingNumbers#closeTo(double, double)}
53+
*/
54+
@Deprecated
55+
public static Matcher<Double> closeTo(double operand, double error) {
56+
return new IsCloseTo(operand, error);
57+
}
4958
}

hamcrest-library/src/main/java/org/hamcrest/number/OrderingComparison.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import org.hamcrest.Matcher;
66
import org.hamcrest.comparator.ComparatorMatcherBuilder;
77

8+
/**
9+
* @deprecated use {@link org.hamcrest.object.MatchingObjects}
10+
*/
811
public class OrderingComparison {
912

1013
private OrderingComparison() {

hamcrest-library/src/main/java/org/hamcrest/object/MatchingObjects.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.hamcrest.collection.IsIn;
66
import org.hamcrest.comparator.ComparatorMatcherBuilder;
77
import org.hamcrest.core.*;
8-
import org.hamcrest.number.OrderingComparison;
98

109
import java.util.EventObject;
1110

@@ -198,7 +197,7 @@ public static <T> Matcher<T> oneOf(T... elements) {
198197
* @param value the value which, when passed to the compareTo method of the examined object, should return zero
199198
*/
200199
public static <T extends Comparable<? super T>> Matcher<T> comparesEqualTo(T value) {
201-
return OrderingComparison.comparesEqualTo(value);
200+
return ComparatorMatcherBuilder.<T>usingNaturalOrdering().comparesEqualTo(value);
202201
}
203202

204203
/**
@@ -212,7 +211,7 @@ public static <T extends Comparable<? super T>> Matcher<T> comparesEqualTo(T val
212211
* than zero
213212
*/
214213
public static <T extends Comparable<? super T>> Matcher<T> greaterThan(T value) {
215-
return OrderingComparison.greaterThan(value);
214+
return ComparatorMatcherBuilder.<T>usingNaturalOrdering().greaterThan(value);
216215
}
217216

218217
/**
@@ -240,7 +239,7 @@ public static <T extends Comparable<? super T>> Matcher<T> greaterThanOrEqualTo(
240239
* than zero
241240
*/
242241
public static <T extends Comparable<? super T>> Matcher<T> lessThan(T value) {
243-
return OrderingComparison.lessThan(value);
242+
return ComparatorMatcherBuilder.<T>usingNaturalOrdering().lessThan(value);
244243
}
245244

246245
/**
@@ -254,7 +253,7 @@ public static <T extends Comparable<? super T>> Matcher<T> lessThan(T value) {
254253
* than or equal to zero
255254
*/
256255
public static <T extends Comparable<? super T>> Matcher<T> lessThanOrEqualTo(T value) {
257-
return OrderingComparison.lessThanOrEqualTo(value);
256+
return ComparatorMatcherBuilder.<T>usingNaturalOrdering().lessThanOrEqualTo(value);
258257
}
259258

260259
/**

0 commit comments

Comments
 (0)