Skip to content

Commit

Permalink
JavaDoc only @return
Browse files Browse the repository at this point in the history
  • Loading branch information
nhojpatrick committed Feb 13, 2022
1 parent a82f91f commit 9bc653b
Show file tree
Hide file tree
Showing 53 changed files with 165 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class EasyMock2Adapter implements IArgumentMatcher {
* Hamcrest {@link org.hamcrest.Matcher} to act as an
* EasyMock {@link org.easymock.IArgumentMatcher} and
* report it to EasyMock so it can be kept track of.
*
* @return The EasyMock matcher.
*/
public static IArgumentMatcher adapt(Matcher<?> matcher) {
EasyMock2Adapter easyMock2Matcher = new EasyMock2Adapter(matcher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class JMock1Adapter implements Constraint {
* Convenience factory method that will adapt a
* Hamcrest {@link org.hamcrest.Matcher} to act as an
* jMock {@link org.jmock.core.Constraint}.
*
* @return The jMock constraint.
*/
public static Constraint adapt(Matcher<?> matcher) {
return new JMock1Adapter(matcher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public abstract class TypeSafeDiagnosingMatcher<T> extends BaseMatcher<T> {
/**
* Subclasses should implement this. The item will already have been checked
* for the specific type and will never be null.
*
* @return boolean true/false depending if item matches matcher.
*/
protected abstract boolean matchesSafely(T item, Description mismatchDescription);

Expand Down
2 changes: 2 additions & 0 deletions hamcrest/src/main/java/org/hamcrest/TypeSafeMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ protected TypeSafeMatcher(ReflectiveTypeFinder typeFinder) {
/**
* Subclasses should implement this. The item will already have been checked for
* the specific type and will never be null.
*
* @return boolean true/false depending if item matches matcher.
*/
protected abstract boolean matchesSafely(T item);

Expand Down
1 change: 1 addition & 0 deletions hamcrest/src/main/java/org/hamcrest/beans/HasProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void describeTo(Description description) {
*
* @param propertyName
* the name of the JavaBean property that examined beans should possess
* @return The matcher.
*/
public static <T> Matcher<T> hasProperty(String propertyName) {
return new HasProperty<T>(propertyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public Condition<Method> apply(PropertyDescriptor property, Description mismatch
* the name of the JavaBean property that examined beans should possess
* @param valueMatcher
* a matcher for the value of the specified property of the examined bean
* @return The matcher.
*/
public static <T> Matcher<T> hasProperty(String propertyName, Matcher<?> valueMatcher) {
return new HasPropertyWithValue<>(propertyName, valueMatcher);
Expand All @@ -176,6 +177,7 @@ public static <T> Matcher<T> hasProperty(String propertyName, Matcher<?> valueMa
* the dot-separated path from the examined object to the JavaBean property
* @param valueMatcher
* a matcher for the value of the specified property of the examined bean
* @return The matcher.
*/
public static <T> Matcher<T> hasPropertyAtPath(String path, Matcher<T> valueMatcher) {
List<String> properties = Arrays.asList(path.split("\\."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private static Object readProperty(Method method, Object target) {
* the bean against which examined beans are compared
* @param ignoredProperties
* do not check any of these named properties.
* @return The matcher.
*/
public static <B> Matcher<B> samePropertyValuesAs(B expectedBean, String... ignoredProperties) {
return new SamePropertyValuesAs<>(expectedBean, asList(ignoredProperties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ArrayMatching {
*
* @param elementMatcher
* the matcher to apply to elements in examined arrays
* @return The matcher.
*/
public static <T> Matcher<T[]> hasItemInArray(Matcher<? super T> elementMatcher) {
return new HasItemInArray<>(elementMatcher);
Expand All @@ -40,6 +41,7 @@ public static <T> Matcher<T[]> hasItemInArray(Matcher<? super T> elementMatcher)
*
* @param element
* the element that should be present in examined arrays
* @return The matcher.
*/
public static <T> Matcher<T[]> hasItemInArray(T element) {
return hasItemInArray(equalTo(element));
Expand All @@ -64,6 +66,7 @@ public static <T> Matcher<T[]> hasItemInArray(T element) {
*
* @param itemMatchers
* a list of matchers, each of which must be satisfied by an entry in an examined array
* @return The matcher.
*/
@SafeVarargs
public static <E> Matcher<E[]> arrayContainingInAnyOrder(Matcher<? super E>... itemMatchers) {
Expand All @@ -89,6 +92,7 @@ public static <E> Matcher<E[]> arrayContainingInAnyOrder(Matcher<? super E>... i
*
* @param itemMatchers
* a list of matchers, each of which must be satisfied by an item provided by an examined array
* @return The matcher.
*/
public static <E> Matcher<E[]> arrayContainingInAnyOrder(Collection<Matcher<? super E>> itemMatchers) {
return new ArrayAsIterableMatcher<>(new IsIterableContainingInAnyOrder<>(itemMatchers), itemMatchers, "in any order");
Expand All @@ -111,6 +115,7 @@ public static <E> Matcher<E[]> arrayContainingInAnyOrder(Collection<Matcher<? su
*
* @param items
* the items that must equal the entries of an examined array, in any order
* @return The matcher.
*/
@SafeVarargs
public static <E> Matcher<E[]> arrayContainingInAnyOrder(E... items) {
Expand All @@ -126,6 +131,7 @@ public static <E> Matcher<E[]> arrayContainingInAnyOrder(E... items) {
*
* @param items
* the items that must equal the items within an examined array
* @return The matcher.
*/
@SafeVarargs
public static <E> Matcher<E[]> arrayContaining(E... items) {
Expand All @@ -140,6 +146,7 @@ public static <E> Matcher<E[]> arrayContaining(E... items) {
*
* @param itemMatchers
* the matchers that must be satisfied by the items in the examined array
* @return The matcher.
*/
@SafeVarargs
public static <E> Matcher<E[]> arrayContaining(Matcher<? super E>... itemMatchers) {
Expand All @@ -159,6 +166,7 @@ public static <E> Matcher<E[]> arrayContaining(Matcher<? super E>... itemMatcher
*
* @param itemMatchers
* a list of matchers, each of which must be satisfied by the corresponding item in an examined array
* @return The matcher.
*/
public static <E> Matcher<E[]> arrayContaining(List<Matcher<? super E>> itemMatchers) {
return new ArrayAsIterableMatcher<>(new IsIterableContainingInOrder<>(itemMatchers), itemMatchers, "");
Expand Down
7 changes: 7 additions & 0 deletions hamcrest/src/main/java/org/hamcrest/collection/IsArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public void describeTo(Description description) {
*
* Can be overridden in subclasses to customise how the matcher is
* described.
*
* @return The description prefix.
*/
protected String descriptionStart() {
return "[";
Expand All @@ -65,6 +67,8 @@ protected String descriptionStart() {
*
* Can be overridden in subclasses to customise how the matcher is
* described.
*
* @return The description separator.
*/
protected String descriptionSeparator() {
return ", ";
Expand All @@ -75,6 +79,8 @@ protected String descriptionSeparator() {
*
* Can be overridden in subclasses to customise how the matcher is
* described.
*
* @return The description suffix.
*/
protected String descriptionEnd() {
return "]";
Expand All @@ -89,6 +95,7 @@ protected String descriptionEnd() {
*
* @param elementMatchers
* the matchers that the elements of examined arrays should satisfy
* @return The matcher.
*/
public static <T> IsArray<T> array(Matcher<? super T>... elementMatchers) {
return new IsArray<T>(elementMatchers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void describeTo(Description description) {
*
* @param itemMatchers
* a list of matchers, each of which must be satisfied by an entry in an examined array
* @return The matcher.
*/
public static <E> Matcher<E[]> arrayContainingInAnyOrder(Matcher<? super E>... itemMatchers) {
return arrayContainingInAnyOrder(Arrays.asList(itemMatchers));
Expand All @@ -79,6 +80,7 @@ public static <E> Matcher<E[]> arrayContainingInAnyOrder(Matcher<? super E>... i
*
* @param itemMatchers
* a list of matchers, each of which must be satisfied by an item provided by an examined array
* @return The matcher.
*/
public static <E> Matcher<E[]> arrayContainingInAnyOrder(Collection<Matcher<? super E>> itemMatchers) {
return new IsArrayContainingInAnyOrder<E>(itemMatchers);
Expand All @@ -101,6 +103,7 @@ public static <E> Matcher<E[]> arrayContainingInAnyOrder(Collection<Matcher<? su
*
* @param items
* the items that must equal the entries of an examined array, in any order
* @return The matcher.
*/
public static <E> Matcher<E[]> arrayContainingInAnyOrder(E... items) {
List<Matcher<? super E>> matchers = new ArrayList<Matcher<? super E>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void describeTo(Description description) {
*
* @param items
* the items that must equal the items within an examined array
* @return The matcher.
*/
public static <E> Matcher<E[]> arrayContaining(E... items) {
List<Matcher<? super E>> matchers = new ArrayList<Matcher<? super E>>();
Expand All @@ -71,6 +72,7 @@ public static <E> Matcher<E[]> arrayContaining(E... items) {
*
* @param itemMatchers
* the matchers that must be satisfied by the items in the examined array
* @return The matcher.
*/
public static <E> Matcher<E[]> arrayContaining(Matcher<? super E>... itemMatchers) {
return arrayContaining(asList(itemMatchers));
Expand All @@ -88,6 +90,7 @@ public static <E> Matcher<E[]> arrayContaining(Matcher<? super E>... itemMatcher
*
* @param itemMatchers
* a list of matchers, each of which must be satisfied by the corresponding item in an examined array
* @return The matcher.
*/
public static <E> Matcher<E[]> arrayContaining(List<Matcher<? super E>> itemMatchers) {
return new IsArrayContainingInOrder<E>(itemMatchers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protected Integer featureValueOf(E[] actual) {
*
* @param sizeMatcher
* a matcher for the length of an examined array
* @return The matcher.
*/
public static <E> Matcher<E[]> arrayWithSize(Matcher<? super Integer> sizeMatcher) {
return new IsArrayWithSize<>(sizeMatcher);
Expand All @@ -40,6 +41,7 @@ public static <E> Matcher<E[]> arrayWithSize(Matcher<? super Integer> sizeMatche
*
* @param size
* the length that an examined array must have for a positive match
* @return The matcher.
*/
public static <E> Matcher<E[]> arrayWithSize(int size) {
return arrayWithSize(equalTo(size));
Expand All @@ -50,6 +52,8 @@ public static <E> Matcher<E[]> arrayWithSize(int size) {
* is zero.
* For example:
* <pre>assertThat(new String[0], emptyArray())</pre>
*
* @return The matcher.
*/
public static <E> Matcher<E[]> emptyArray() {
return describedAs("an empty array", IsArrayWithSize.<E>arrayWithSize(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected Integer featureValueOf(Collection<? extends E> actual) {
*
* @param sizeMatcher
* a matcher for the size of an examined {@link java.util.Collection}
* @return The matcher.
*/
public static <E> Matcher<Collection<? extends E>> hasSize(Matcher<? super Integer> sizeMatcher) {
return new IsCollectionWithSize<E>(sizeMatcher);
Expand All @@ -41,6 +42,7 @@ public static <E> Matcher<Collection<? extends E>> hasSize(Matcher<? super Integ
*
* @param size
* the expected size of an examined {@link java.util.Collection}
* @return The matcher.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <E> Matcher<Collection<? extends E>> hasSize(int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public void describeTo(Description description) {
* method returns <code>true</code>.
* For example:
* <pre>assertThat(new ArrayList&lt;String&gt;(), is(empty()))</pre>
*
* @return The matcher.
*/
public static <E> Matcher<Collection<? extends E>> empty() {
return new IsEmptyCollection<E>();
Expand All @@ -44,6 +46,7 @@ public static <E> Matcher<Collection<? extends E>> empty() {
*
* @param unusedToForceReturnType
* the type of the collection's content
* @return The matcher.
*/
@SuppressWarnings({"unchecked", "UnusedParameters"})
public static <E> Matcher<Collection<E>> emptyCollectionOf(Class<E> unusedToForceReturnType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public void describeTo(Description description) {
* Creates a matcher for {@link Iterable}s matching examined iterables that yield no items.
* For example:
* <pre>assertThat(new ArrayList&lt;String&gt;(), is(emptyIterable()))</pre>
*
* @return The matcher.
*/
public static <E> Matcher<Iterable<? extends E>> emptyIterable() {
return new IsEmptyIterable<E>();
Expand All @@ -39,6 +41,7 @@ public static <E> Matcher<Iterable<? extends E>> emptyIterable() {
*
* @param unusedToForceReturnType
* the type of the iterable's content
* @return The matcher.
*/
@SuppressWarnings({"unchecked", "UnusedParameters"})
public static <E> Matcher<Iterable<E>> emptyIterableOf(Class<E> unusedToForceReturnType) {
Expand Down
10 changes: 8 additions & 2 deletions hamcrest/src/main/java/org/hamcrest/collection/IsIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public void describeTo(Description buffer) {
*
* @param collection
* the collection in which matching items must be found
* @return The matcher.
*/
@Deprecated
public static <T> Matcher<T> isIn(Collection<T> collection) {
Expand All @@ -54,6 +55,7 @@ public static <T> Matcher<T> isIn(Collection<T> collection) {
*
* @param collection
* the collection in which matching items must be found
* @return The matcher.
*/
public static <T> Matcher<T> in(Collection<T> collection) {
return new IsIn<>(collection);
Expand All @@ -69,6 +71,7 @@ public static <T> Matcher<T> in(Collection<T> collection) {
*
* @param elements
* the array in which matching items must be found
* @return The matcher.
*/
@Deprecated
public static <T> Matcher<T> isIn(T[] elements) {
Expand All @@ -83,6 +86,7 @@ public static <T> Matcher<T> isIn(T[] elements) {
*
* @param elements
* the array in which matching items must be found
* @return The matcher.
*/
public static <T> Matcher<T> in(T[] elements) {
return new IsIn<>(elements);
Expand All @@ -97,7 +101,8 @@ public static <T> Matcher<T> in(T[] elements) {
* @deprecated use is(oneOf(...)) instead
*
* @param elements
* the elements amongst which matching items will be found
* the elements amongst which matching items will be found
* @return The matcher.
*/
@SafeVarargs
@Deprecated
Expand All @@ -112,7 +117,8 @@ public static <T> Matcher<T> isOneOf(T... elements) {
* <pre>assertThat("foo", is(oneOf("bar", "foo")))</pre>
*
* @param elements
* the elements amongst which matching items will be found
* the elements amongst which matching items will be found
* @return The matcher.
*/
@SafeVarargs
public static <T> Matcher<T> oneOf(T... elements) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private boolean isMatched(S item) {
*
* @param itemMatchers
* a list of matchers, each of which must be satisfied by an item provided by an examined {@link Iterable}
* @return The matcher.
*/
@SafeVarargs
public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(Matcher<? super T>... itemMatchers) {
Expand All @@ -120,6 +121,7 @@ public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(Matcher<? su
*
* @param items
* the items that must equal the items provided by an examined {@link Iterable} in any order
* @return The matcher.
*/
@SafeVarargs
public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(T... items) {
Expand Down Expand Up @@ -148,6 +150,7 @@ public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(T... items)
*
* @param itemMatchers
* a list of matchers, each of which must be satisfied by an item provided by an examined {@link Iterable}
* @return The matcher.
*/
public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(Collection<Matcher<? super T>> itemMatchers) {
return new IsIterableContainingInAnyOrder<>(itemMatchers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ private void describeMismatch(Matcher<? super F> matcher, F item) {
*
* @param items
* the items that must equal the items provided by an examined {@link Iterable}
* @return The matcher.
*/
@SafeVarargs
public static <E> Matcher<Iterable<? extends E>> contains(E... items) {
Expand All @@ -107,6 +108,7 @@ public static <E> Matcher<Iterable<? extends E>> contains(E... items) {
* @param itemMatcher
* the matcher that must be satisfied by the single item provided by an
* examined {@link Iterable}
* @return The matcher.
*/
@SuppressWarnings("unchecked")
public static <E> Matcher<Iterable<? extends E>> contains(final Matcher<? super E> itemMatcher) {
Expand All @@ -123,6 +125,7 @@ public static <E> Matcher<Iterable<? extends E>> contains(final Matcher<? super
*
* @param itemMatchers
* the matchers that must be satisfied by the items provided by an examined {@link Iterable}
* @return The matcher.
*/
@SafeVarargs
public static <E> Matcher<Iterable<? extends E>> contains(Matcher<? super E>... itemMatchers) {
Expand All @@ -143,6 +146,7 @@ public static <E> Matcher<Iterable<? extends E>> contains(Matcher<? super E>...
* @param itemMatchers
* a list of matchers, each of which must be satisfied by the corresponding item provided by
* an examined {@link Iterable}
* @return The matcher.
*/
public static <E> Matcher<Iterable<? extends E>> contains(List<Matcher<? super E>> itemMatchers) {
return new IsIterableContainingInOrder<>(itemMatchers);
Expand Down
Loading

0 comments on commit 9bc653b

Please sign in to comment.