Skip to content

Commit 4fd60a9

Browse files
committed
Factory methods. Bean has property
1 parent 755e9a4 commit 4fd60a9

File tree

6 files changed

+10
-37
lines changed

6 files changed

+10
-37
lines changed

hamcrest-library/src/main/java/org/hamcrest/Matchers.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.hamcrest;
22

3+
import org.hamcrest.beans.MatchingBeans;
34
import org.hamcrest.collection.MatchingArrays;
45
import org.hamcrest.collection.MatchingCollections;
56
import org.hamcrest.collection.MatchingIterables;
@@ -1424,7 +1425,7 @@ public static org.hamcrest.Matcher<java.util.EventObject> eventFrom(Object sourc
14241425
* @param propertyName the name of the JavaBean property that examined beans should possess
14251426
*/
14261427
public static <T> Matcher<T> hasProperty(java.lang.String propertyName) {
1427-
return org.hamcrest.beans.HasProperty.hasProperty(propertyName);
1428+
return MatchingBeans.hasProperty(propertyName);
14281429
}
14291430

14301431
/**
@@ -1437,7 +1438,7 @@ public static <T> Matcher<T> hasProperty(java.lang.String propertyName) {
14371438
* @param valueMatcher a matcher for the value of the specified property of the examined bean
14381439
*/
14391440
public static <T> Matcher<T> hasProperty(java.lang.String propertyName, org.hamcrest.Matcher<?> valueMatcher) {
1440-
return org.hamcrest.beans.HasPropertyWithValue.hasProperty(propertyName, valueMatcher);
1441+
return MatchingBeans.hasProperty(propertyName, valueMatcher);
14411442
}
14421443

14431444
/**

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

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

55
import org.hamcrest.Description;
6-
import org.hamcrest.Matcher;
76
import org.hamcrest.TypeSafeMatcher;
87

98
/**
@@ -42,17 +41,4 @@ public void describeTo(Description description) {
4241
description.appendText("hasProperty(").appendValue(propertyName).appendText(")");
4342
}
4443

45-
/**
46-
* Creates a matcher that matches when the examined object has a JavaBean property
47-
* with the specified name.
48-
* For example:
49-
* <pre>assertThat(myBean, hasProperty("foo"))</pre>
50-
*
51-
* @param propertyName
52-
* the name of the JavaBean property that examined beans should possess
53-
*/
54-
public static <T> Matcher<T> hasProperty(String propertyName) {
55-
return new HasProperty<>(propertyName);
56-
}
57-
5844
}

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

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

136-
/**
137-
* Creates a matcher that matches when the examined object has a JavaBean property
138-
* with the specified name whose value satisfies the specified matcher.
139-
* For example:
140-
* <pre>assertThat(myBean, hasProperty("foo", equalTo("bar"))</pre>
141-
*
142-
* @param propertyName
143-
* the name of the JavaBean property that examined beans should possess
144-
* @param valueMatcher
145-
* a matcher for the value of the specified property of the examined bean
146-
*/
147-
public static <T> Matcher<T> hasProperty(String propertyName, Matcher<?> valueMatcher) {
148-
return new HasPropertyWithValue<>(propertyName, valueMatcher);
149-
}
150136
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class MatchingBeans {
1010
* @param propertyName the name of the JavaBean property that examined beans should possess
1111
*/
1212
public static <T> org.hamcrest.Matcher<T> hasProperty(java.lang.String propertyName) {
13-
return org.hamcrest.beans.HasProperty.hasProperty(propertyName);
13+
return new HasProperty<>(propertyName);
1414
}
1515

1616
/**
@@ -23,7 +23,7 @@ public static <T> org.hamcrest.Matcher<T> hasProperty(java.lang.String propertyN
2323
* @param valueMatcher a matcher for the value of the specified property of the examined bean
2424
*/
2525
public static <T> org.hamcrest.Matcher<T> hasProperty(java.lang.String propertyName, org.hamcrest.Matcher<?> valueMatcher) {
26-
return org.hamcrest.beans.HasPropertyWithValue.hasProperty(propertyName, valueMatcher);
26+
return new HasPropertyWithValue<>(propertyName, valueMatcher);
2727
}
2828

2929
/**

hamcrest-library/src/test/java/org/hamcrest/beans/HasPropertyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.junit.Test;
77

88
import static org.hamcrest.AbstractMatcherTest.*;
9-
import static org.hamcrest.beans.HasProperty.hasProperty;
9+
import static org.hamcrest.beans.MatchingBeans.hasProperty;
1010

1111
/**
1212
* @author Iain McGinniss

hamcrest-library/src/test/java/org/hamcrest/beans/HasPropertyWithValueTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
import java.beans.SimpleBeanInfo;
1414

1515
import static org.hamcrest.MatcherAssert.assertThat;
16-
import static org.hamcrest.beans.HasPropertyWithValue.hasProperty;
17-
import static org.hamcrest.core.IsAnything.anything;
18-
import static org.hamcrest.core.IsEqual.equalTo;
16+
import static org.hamcrest.beans.MatchingBeans.hasProperty;
17+
import static org.hamcrest.object.MatchingObjects.anything;
18+
import static org.hamcrest.object.MatchingObjects.equalTo;
1919

2020
/**
2121
* @author Iain McGinniss
@@ -83,7 +83,7 @@ public int getTest() {
8383
}
8484
}
8585

86-
assertThat(new X(), HasPropertyWithValue.hasProperty("test", IsEqual.equalTo(1)));
86+
assertThat(new X(), MatchingBeans.hasProperty("test", IsEqual.equalTo(1)));
8787
}
8888

8989
interface IX {

0 commit comments

Comments
 (0)