From 2ab54c79ed227d5eaa0d66f5fb84cb0b29b07c97 Mon Sep 17 00:00:00 2001
From: JJ Brown
* assertThat("foo", equalTo("foo")); @@ -244,7 +244,7 @@ public static org.hamcrest.MatcherequalToObject(java.lang.Obj * Creates a matcher that matches when the examined object is an instance of the specified type
, * as determined by calling the {@link java.lang.Class#isInstance(Object)} method on that type, passing the * the examined object. - * + * *The created matcher forces a relationship between specified type and the examined object, and should be * used when it is necessary to make generics conform, for example in the JMock clause *
@@ -259,7 +259,7 @@ public staticwith(any(Thing.class))
org.hamcrest.Matcher any(java.lang.Class type) { * Creates a matcher that matches when the examined object is an instance of the specified type
, * as determined by calling the {@link java.lang.Class#isInstance(Object)} method on that type, passing the * the examined object. - * + * *The created matcher assumes no relationship between specified type and the examined object.
* For example: *assertThat(new Canoe(), instanceOf(Paddlable.class));@@ -273,7 +273,7 @@ public staticorg.hamcrest.Matcher instanceOf(java.lang.Class> type) { * it will match. * For example: * assertThat(cheese, is(not(equalTo(smelly))))- * + * * @param matcher * the matcher whose sense should be inverted */ @@ -287,7 +287,7 @@ public staticorg.hamcrest.Matcher not(org.hamcrest.Matcher matcher) { * assertThat(cheese, is(not(smelly)))* instead of: *assertThat(cheese, is(not(equalTo(smelly))))- * + * * @param value * the value that any examined object should not equal */ @@ -313,7 +313,7 @@ public static org.hamcrest.MatchernotNullValue() { * assertThat(cheese, is(notNullValue(X.class)))* instead of: *assertThat(cheese, is(not(nullValue(X.class))))- * + * * @param type * dummy parameter used to infer the generic type of the returned matcher */ @@ -335,7 +335,7 @@ public static org.hamcrest.MatchernullValue() { * single dummy argument to facilitate type inference. * For example: * assertThat(cheese, is(nullValue(Cheese.class))- * + * * @param type * dummy parameter used to infer the generic type of the returned matcher */ @@ -346,7 +346,7 @@ public staticorg.hamcrest.Matcher nullValue(java.lang.Class type) { /** * Creates a matcher that matches only when the examined object is the same instance as * the specified target object. - * + * * @param target * the target instance against which others should be assessed */ @@ -357,7 +357,7 @@ public static org.hamcrest.Matcher sameInstance(T target) { /** * Creates a matcher that matches only when the examined object is the same instance as * the specified target object. - * + * * @param target * the target instance against which others should be assessed */ @@ -370,7 +370,7 @@ public static org.hamcrest.Matcher theInstance(T target) { * {@link String} anywhere. * For example: * assertThat("myStringOfNote", containsString("ring"))- * + * * @param substring * the substring that the returned matcher will expect to find within any examined string */ @@ -383,7 +383,7 @@ public static org.hamcrest.MatchercontainsString(java.lang.St * {@link String} anywhere, ignoring case. * For example: * assertThat("myStringOfNote", containsString("ring"))- * + * * @param substring * the substring that the returned matcher will expect to find within any examined string */ @@ -398,7 +398,7 @@ public static org.hamcrest.MatchercontainsStringIgnoringCase( * * For example: * assertThat("myStringOfNote", startsWith("my"))- * + * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ @@ -413,7 +413,7 @@ public static org.hamcrest.MatcherstartsWith(java.lang.String * * For example: * assertThat("myStringOfNote", startsWith("my"))- * + * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ @@ -426,7 +426,7 @@ public static org.hamcrest.MatcherstartsWithIgnoringCase(java * {@link String}. * For example: * assertThat("myStringOfNote", endsWith("Note"))- * + * * @param suffix * the substring that the returned matcher will expect at the end of any examined string */ @@ -439,7 +439,7 @@ public static org.hamcrest.MatcherendsWith(java.lang.String s * {@link String}, ignoring case. * For example: * assertThat("myStringOfNote", endsWith("Note"))- * + * * @param suffix * the substring that the returned matcher will expect at the end of any examined string */ diff --git a/hamcrest/src/main/java/org/hamcrest/CustomMatcher.java b/hamcrest/src/main/java/org/hamcrest/CustomMatcher.java index 036a7640..a322b2b3 100644 --- a/hamcrest/src/main/java/org/hamcrest/CustomMatcher.java +++ b/hamcrest/src/main/java/org/hamcrest/CustomMatcher.java @@ -17,21 +17,21 @@ * * @author Neil Dunn * @see CustomTypeSafeMatcher for a type safe variant of this class that you probably - * want to use. + * want to use. * @paramThe type of object being matched. */ public abstract class CustomMatcher extends BaseMatcher { - private final String fixedDescription; + private final String fixedDescription; - public CustomMatcher(String description) { - if (description == null) { - throw new IllegalArgumentException("Description should be non null!"); - } - this.fixedDescription = description; + public CustomMatcher(String description) { + if (description == null) { + throw new IllegalArgumentException("Description should be non null!"); } + this.fixedDescription = description; + } - @Override - public final void describeTo(Description description) { - description.appendText(fixedDescription); - } + @Override + public final void describeTo(Description description) { + description.appendText(fixedDescription); + } } diff --git a/hamcrest/src/main/java/org/hamcrest/CustomTypeSafeMatcher.java b/hamcrest/src/main/java/org/hamcrest/CustomTypeSafeMatcher.java index 7c5c46ce..31efec4e 100644 --- a/hamcrest/src/main/java/org/hamcrest/CustomTypeSafeMatcher.java +++ b/hamcrest/src/main/java/org/hamcrest/CustomTypeSafeMatcher.java @@ -23,17 +23,17 @@ * @param The type of object being matched */ public abstract class CustomTypeSafeMatcher extends TypeSafeMatcher { - private final String fixedDescription; + private final String fixedDescription; - public CustomTypeSafeMatcher(String description) { - if (description == null) { - throw new IllegalArgumentException("Description must be non null!"); - } - this.fixedDescription = description; + public CustomTypeSafeMatcher(String description) { + if (description == null) { + throw new IllegalArgumentException("Description must be non null!"); } + this.fixedDescription = description; + } - @Override - public final void describeTo(Description description) { - description.appendText(fixedDescription); - } + @Override + public final void describeTo(Description description) { + description.appendText(fixedDescription); + } } diff --git a/hamcrest/src/main/java/org/hamcrest/Description.java b/hamcrest/src/main/java/org/hamcrest/Description.java index 73bfa385..ddbcc4b5 100644 --- a/hamcrest/src/main/java/org/hamcrest/Description.java +++ b/hamcrest/src/main/java/org/hamcrest/Description.java @@ -11,79 +11,79 @@ public interface Description { * A description that consumes input but does nothing. */ static final Description NONE = new NullDescription(); - - /** - * Appends some plain text to the description. - */ - Description appendText(String text); - /** - * Appends the description of a {@link SelfDescribing} value to this description. - */ - Description appendDescriptionOf(SelfDescribing value); + /** + * Appends some plain text to the description. + */ + Description appendText(String text); - /** - * Appends an arbitrary value to the description. - */ - Description appendValue(Object value); + /** + * Appends the description of a {@link SelfDescribing} value to this description. + */ + Description appendDescriptionOf(SelfDescribing value); - /** - * Appends a list of values to the description. - */ - Description appendValueList(String start, String separator, String end, - T... values); + /** + * Appends an arbitrary value to the description. + */ + Description appendValue(Object value); - /** - * Appends a list of values to the description. - */ - Description appendValueList(String start, String separator, String end, - Iterable values); + /** + * Appends a list of values to the description. + */ + Description appendValueList(String start, String separator, String end, + T... values); - /** - * Appends a list of {@link org.hamcrest.SelfDescribing} objects - * to the description. - */ - Description appendList(String start, String separator, String end, - Iterable extends SelfDescribing> values); + /** + * Appends a list of values to the description. + */ + Description appendValueList(String start, String separator, String end, + Iterable values); + /** + * Appends a list of {@link org.hamcrest.SelfDescribing} objects + * to the description. + */ + Description appendList(String start, String separator, String end, + Iterable extends SelfDescribing> values); - public static final class NullDescription implements Description { - @Override - public Description appendDescriptionOf(SelfDescribing value) { - return this; - } - @Override - public Description appendList(String start, String separator, - String end, Iterable extends SelfDescribing> values) { - return this; - } + public static final class NullDescription implements Description { + @Override + public Description appendDescriptionOf(SelfDescribing value) { + return this; + } - @Override - public Description appendText(String text) { - return this; - } + @Override + public Description appendList(String start, String separator, + String end, Iterable extends SelfDescribing> values) { + return this; + } - @Override - public Description appendValue(Object value) { - return this; - } + @Override + public Description appendText(String text) { + return this; + } - @Override - public Description appendValueList(String start, String separator, - String end, T... values) { - return this; - } + @Override + public Description appendValue(Object value) { + return this; + } + + @Override + public Description appendValueList(String start, String separator, + String end, T... values) { + return this; + } - @Override - public Description appendValueList(String start, String separator, - String end, Iterable values) { - return this; - } + @Override + public Description appendValueList(String start, String separator, + String end, Iterable values) { + return this; + } - @Override - public String toString() { - return ""; - } + @Override + public String toString() { + return ""; } + } } diff --git a/hamcrest/src/main/java/org/hamcrest/DiagnosingMatcher.java b/hamcrest/src/main/java/org/hamcrest/DiagnosingMatcher.java index f87de2df..929aa277 100644 --- a/hamcrest/src/main/java/org/hamcrest/DiagnosingMatcher.java +++ b/hamcrest/src/main/java/org/hamcrest/DiagnosingMatcher.java @@ -7,15 +7,15 @@ */ public abstract class DiagnosingMatcher extends BaseMatcher { - @Override - public final boolean matches(Object item) { - return matches(item, Description.NONE); - } + @Override + public final boolean matches(Object item) { + return matches(item, Description.NONE); + } - @Override - public final void describeMismatch(Object item, Description mismatchDescription) { - matches(item, mismatchDescription); - } + @Override + public final void describeMismatch(Object item, Description mismatchDescription) { + matches(item, mismatchDescription); + } - protected abstract boolean matches(Object item, Description mismatchDescription); + protected abstract boolean matches(Object item, Description mismatchDescription); } diff --git a/hamcrest/src/main/java/org/hamcrest/FeatureMatcher.java b/hamcrest/src/main/java/org/hamcrest/FeatureMatcher.java index 385cf999..f0ab22fe 100644 --- a/hamcrest/src/main/java/org/hamcrest/FeatureMatcher.java +++ b/hamcrest/src/main/java/org/hamcrest/FeatureMatcher.java @@ -4,22 +4,22 @@ /** * Supporting class for matching a feature of an object. Implement featureValueOf()
- * in a subclass to pull out the feature to be matched against. + * in a subclass to pull out the feature to be matched against. * * @paramThe type of the object to be matched * @param The type of the feature to be matched */ public abstract class FeatureMatcher extends TypeSafeDiagnosingMatcher { - private static final ReflectiveTypeFinder TYPE_FINDER = new ReflectiveTypeFinder("featureValueOf", 1, 0); + private static final ReflectiveTypeFinder TYPE_FINDER = new ReflectiveTypeFinder("featureValueOf", 1, 0); private final Matcher super U> subMatcher; private final String featureDescription; private final String featureName; - + /** * Constructor - * @param subMatcher The matcher to apply to the feature + * @param subMatcher The matcher to apply to the feature * @param featureDescription Descriptive text to use in describeTo - * @param featureName Identifying text for mismatch message + * @param featureName Identifying text for mismatch message */ public FeatureMatcher(Matcher super U> subMatcher, String featureDescription, String featureName) { super(TYPE_FINDER); @@ -27,7 +27,7 @@ public FeatureMatcher(Matcher super U> subMatcher, String featureDescription, this.featureDescription = featureDescription; this.featureName = featureName; } - + /** * Implement this to extract the interesting feature. * @param actual the target object @@ -45,10 +45,10 @@ protected boolean matchesSafely(T actual, Description mismatch) { } return true; } - + @Override public final void describeTo(Description description) { description.appendText(featureDescription).appendText(" ") - .appendDescriptionOf(subMatcher); + .appendDescriptionOf(subMatcher); } } diff --git a/hamcrest/src/main/java/org/hamcrest/Matcher.java b/hamcrest/src/main/java/org/hamcrest/Matcher.java index 77e09d5b..43366f69 100644 --- a/hamcrest/src/main/java/org/hamcrest/Matcher.java +++ b/hamcrest/src/main/java/org/hamcrest/Matcher.java @@ -25,43 +25,43 @@ */ public interface Matcher extends SelfDescribing { - /** - * Evaluates the matcher for argument item. + /** + * Evaluates the matcher for argument item. + * + * This method matches against Object, instead of the generic type T. This is + * because the caller of the Matcher does not know at runtime what the type is + * (because of type erasure with Java generics). It is down to the implementations + * to check the correct type. + * + * @param actual the object against which the matcher is evaluated. + * @return true
if item matches, otherwisefalse
. * - * This method matches against Object, instead of the generic type T. This is - * because the caller of the Matcher does not know at runtime what the type is - * (because of type erasure with Java generics). It is down to the implementations - * to check the correct type. - * - * @param actual the object against which the matcher is evaluated. - * @returntrue
if item matches, otherwisefalse
. - * - * @see BaseMatcher - */ - boolean matches(Object actual); - - /** - * Generate a description of why the matcher has not accepted the item. - * The description will be part of a larger description of why a matching - * failed, so it should be concise. - * This method assumes thatmatches(item)
is false, but - * will not check this. - * - * @param actual The item that the Matcher has rejected. + * @see BaseMatcher + */ + boolean matches(Object actual); + + /** + * Generate a description of why the matcher has not accepted the item. + * The description will be part of a larger description of why a matching + * failed, so it should be concise. + * This method assumes thatmatches(item)
is false, but + * will not check this. + * + * @param actual The item that the Matcher has rejected. * @param mismatchDescription * The description to be built or appended to. - */ - void describeMismatch(Object actual, Description mismatchDescription); + */ + void describeMismatch(Object actual, Description mismatchDescription); - /** - * This method simply acts a friendly reminder not to implement Matcher directly and - * instead extend BaseMatcher. It's easy to ignore JavaDoc, but a bit harder to ignore - * compile errors . - * - * @see Matcher for reasons why. - * @see BaseMatcher - * @deprecated to make - */ - @Deprecated - void _dont_implement_Matcher___instead_extend_BaseMatcher_(); + /** + * This method simply acts a friendly reminder not to implement Matcher directly and + * instead extend BaseMatcher. It's easy to ignore JavaDoc, but a bit harder to ignore + * compile errors . + * + * @see Matcher for reasons why. + * @see BaseMatcher + * @deprecated to make + */ + @Deprecated + void _dont_implement_Matcher___instead_extend_BaseMatcher_(); } diff --git a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java index bc001ebb..c0614934 100644 --- a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java +++ b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java @@ -2,28 +2,28 @@ public class MatcherAssert { - public staticvoid assertThat(T actual, Matcher super T> matcher) { - assertThat("", actual, matcher); - } - - public static void assertThat(String reason, T actual, Matcher super T> matcher) { - if (!matcher.matches(actual)) { - Description description = new StringDescription(); - description.appendText(reason) - .appendText(System.lineSeparator()) - .appendText("Expected: ") - .appendDescriptionOf(matcher) - .appendText(System.lineSeparator()) - .appendText(" but: "); - matcher.describeMismatch(actual, description); - - throw new AssertionError(description.toString()); - } + public static void assertThat(T actual, Matcher super T> matcher) { + assertThat("", actual, matcher); + } + + public static void assertThat(String reason, T actual, Matcher super T> matcher) { + if (!matcher.matches(actual)) { + Description description = new StringDescription(); + description.appendText(reason) + .appendText(System.lineSeparator()) + .appendText("Expected: ") + .appendDescriptionOf(matcher) + .appendText(System.lineSeparator()) + .appendText(" but: "); + matcher.describeMismatch(actual, description); + + throw new AssertionError(description.toString()); } - - public static void assertThat(String reason, boolean assertion) { - if (!assertion) { - throw new AssertionError(reason); - } + } + + public static void assertThat(String reason, boolean assertion) { + if (!assertion) { + throw new AssertionError(reason); } + } } diff --git a/hamcrest/src/main/java/org/hamcrest/Matchers.java b/hamcrest/src/main/java/org/hamcrest/Matchers.java index 30064b12..5d98de60 100644 --- a/hamcrest/src/main/java/org/hamcrest/Matchers.java +++ b/hamcrest/src/main/java/org/hamcrest/Matchers.java @@ -161,7 +161,7 @@ public static org.hamcrest.core.CombinableMatcher.CombinableEitherMatcher< * delegated to the decorated matcher, including its mismatch description. * For example: * describedAs("a big decimal equal to %0", equalTo(myBigDecimal), myBigDecimal.toPlainString())- * + * * @param description * the new description for the wrapped matcher * @param matcher @@ -179,7 +179,7 @@ public staticorg.hamcrest.Matcher describedAs(java.lang.String descripti * itemMatcher
. * For example: *assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))- * + * * @param itemMatcher * the matcher to apply to every item provided by the examined {@link Iterable} */ @@ -231,7 +231,7 @@ public static org.hamcrest.Matcheranything() { /** * Creates a matcher that always matches, regardless of the examined object, but describes * itself with the specified {@link String}. - * + * * @param description * a meaningful {@link String} used when describing itself */ @@ -246,7 +246,7 @@ public static org.hamcrest.Matcher anything(java.lang.String d * will stop as soon as a matching item is found. * For example: * assertThat(Arrays.asList("foo", "bar"), hasItem(startsWith("ba")))- * + * * @param itemMatcher * the matcher to apply to items provided by the examined {@link Iterable} */ @@ -261,7 +261,7 @@ public staticorg.hamcrest.Matcher > hasItem(or * will stop as soon as a matching item is found. * For example: * assertThat(Arrays.asList("foo", "bar"), hasItem("bar"))- * + * * @param item * the item to compare against the items provided by the examined {@link Iterable} */ @@ -276,7 +276,7 @@ public staticorg.hamcrest.Matcher > hasItem(T * the examined {@link Iterable} will stop as soon as a matching item is found. * For example: * assertThat(Arrays.asList("foo", "bar", "baz"), hasItems(endsWith("z"), endsWith("o")))- * + * * @param itemMatchers * the matchers to apply to items provided by the examined {@link Iterable} */ @@ -292,7 +292,7 @@ public staticorg.hamcrest.Matcher > hasItems(org.hamcr * examined {@link Iterable} will stop as soon as a matching item is found. * For example: * assertThat(Arrays.asList("foo", "bar", "baz"), hasItems("baz", "foo"))- * + * * @param items * the items to compare against the items provided by the examined {@link Iterable} */ @@ -305,17 +305,17 @@ public staticorg.hamcrest.Matcher > hasItems(T... item * Creates a matcher that matches when the examined object is logically equal to the specified * operand
, as determined by calling the {@link java.lang.Object#equals} method on * the examined object. - * + * *If the specified operand is
- * + * *null
then the created matcher will only match if * the examined object'sequals
method returnstrue
when passed a *null
(which would be a violation of theequals
contract), unless the * examined object itself isnull
, in which case the matcher will return a positive * match.The created matcher provides a special behaviour when examining
+ * indexes. * For example: *Array
s, whereby * it will match if both the operand and the examined object are arrays of the same length and * contain items that are equal to each other (according to the above rules) in the same - * indexes.* assertThat("foo", equalTo("foo")); @@ -338,7 +338,7 @@ public static org.hamcrest.MatcherequalToObject(java.lang.Obj * Creates a matcher that matches when the examined object is an instance of the specified type
, * as determined by calling the {@link java.lang.Class#isInstance(Object)} method on that type, passing the * the examined object. - * + * *The created matcher forces a relationship between specified type and the examined object, and should be * used when it is necessary to make generics conform, for example in the JMock clause *
@@ -353,7 +353,7 @@ public staticwith(any(Thing.class))
org.hamcrest.Matcher any(java.lang.Class type) { * Creates a matcher that matches when the examined object is an instance of the specified type
, * as determined by calling the {@link java.lang.Class#isInstance(Object)} method on that type, passing the * the examined object. - * + * *The created matcher assumes no relationship between specified type and the examined object.
* For example: *assertThat(new Canoe(), instanceOf(Paddlable.class));@@ -367,7 +367,7 @@ public staticorg.hamcrest.Matcher instanceOf(java.lang.Class> type) { * it will match. * For example: * assertThat(cheese, is(not(equalTo(smelly))))- * + * * @param matcher * the matcher whose sense should be inverted */ @@ -381,7 +381,7 @@ public staticorg.hamcrest.Matcher not(org.hamcrest.Matcher matcher) { * assertThat(cheese, is(not(smelly)))* instead of: *assertThat(cheese, is(not(equalTo(smelly))))- * + * * @param value * the value that any examined object should not equal */ @@ -407,7 +407,7 @@ public static org.hamcrest.MatchernotNullValue() { * assertThat(cheese, is(notNullValue(X.class)))* instead of: *assertThat(cheese, is(not(nullValue(X.class))))- * + * * @param type * dummy parameter used to infer the generic type of the returned matcher */ @@ -429,7 +429,7 @@ public static org.hamcrest.MatchernullValue() { * single dummy argument to facilitate type inference. * For example: * assertThat(cheese, is(nullValue(Cheese.class))- * + * * @param type * dummy parameter used to infer the generic type of the returned matcher */ @@ -440,7 +440,7 @@ public staticorg.hamcrest.Matcher nullValue(java.lang.Class type) { /** * Creates a matcher that matches only when the examined object is the same instance as * the specified target object. - * + * * @param target * the target instance against which others should be assessed */ @@ -451,20 +451,20 @@ public static org.hamcrest.Matcher sameInstance(T target) { /** * Creates a matcher that matches only when the examined object is the same instance as * the specified target object. - * + * * @param target * the target instance against which others should be assessed */ public static org.hamcrest.Matcher theInstance(T target) { return org.hamcrest.core.IsSame.theInstance(target); } - + /** * Creates a matcher that matches if the examined {@link String} contains the specified * {@link String} anywhere. * For example: * assertThat("myStringOfNote", containsString("ring"))- * + * * @param substring * the substring that the returned matcher will expect to find within any examined string */ @@ -477,7 +477,7 @@ public static MatchercontainsString(java.lang.String substrin * {@link String} anywhere, ignoring case. * For example: * assertThat("myStringOfNote", containsStringIgnoringCase("Ring"))- * + * * @param substring * the substring that the returned matcher will expect to find within any examined string */ @@ -492,7 +492,7 @@ public static MatchercontainsStringIgnoringCase(java.lang.Str * * For example: * assertThat("myStringOfNote", startsWith("my"))- * + * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ @@ -507,7 +507,7 @@ public static MatcherstartsWith(java.lang.String prefix) { * * For example: * assertThat("myStringOfNote", startsWithIgnoringCase("My"))- * + * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ @@ -520,7 +520,7 @@ public static MatcherstartsWithIgnoringCase(java.lang.String * {@link String}. * For example: * assertThat("myStringOfNote", endsWith("Note"))- * + * * @param suffix * the substring that the returned matcher will expect at the end of any examined string */ @@ -533,7 +533,7 @@ public static MatcherendsWith(java.lang.String suffix) { * {@link String}, ignoring case. * For example: * assertThat("myStringOfNote", endsWithIgnoringCase("note"))- * + * * @param suffix * the substring that the returned matcher will expect at the end of any examined string */ @@ -577,7 +577,7 @@ public static MatchermatchesRegex(String regex) { * each matcher[i] is satisfied by array[i]. * For example: * assertThat(new Integer[]{1,2,3}, is(array(equalTo(1), equalTo(2), equalTo(3))))- * + * * @param elementMatchers * the matchers that the elements of examined arrays should satisfy */ @@ -592,7 +592,7 @@ public staticorg.hamcrest.collection.IsArray array(org.hamcrest.Matcher< * of the examined array will stop as soon as a matching element is found. * For example: * assertThat(new String[] {"foo", "bar"}, hasItemInArray(startsWith("ba")))- * + * * @param elementMatcher * the matcher to apply to elements in examined arrays */ @@ -606,7 +606,7 @@ public staticorg.hamcrest.Matcher hasItemInArray(org.hamcrest.Matcher< * assertThat(hasItemInArray(x))* instead of: *assertThat(hasItemInArray(equalTo(x)))- * + * * @param element * the element that should be present in examined arrays */ @@ -620,7 +620,7 @@ public staticorg.hamcrest.Matcher hasItemInArray(T element) { * the examined array must be of the same length as the number of specified items. * For example: * assertThat(new String[]{"foo", "bar"}, arrayContaining("foo", "bar"))- * + * * @param items * the items that must equal the items within an examined array */ @@ -635,7 +635,7 @@ public staticorg.hamcrest.Matcher arrayContaining(E... items) { * must be of the same length as the number of specified matchers. * For example: * assertThat(new String[]{"foo", "bar"}, arrayContaining(equalTo("foo"), equalTo("bar")))- * + * * @param itemMatchers * the matchers that must be satisfied by the items in the examined array */ @@ -650,7 +650,7 @@ public staticorg.hamcrest.Matcher arrayContaining(org.hamcrest.Matcher * must be of the same length as the specified list of matchers. * For example: * assertThat(new String[]{"foo", "bar"}, arrayContaining(Arrays.asList(equalTo("foo"), equalTo("bar"))))- * + * * @param itemMatchers * a list of matchers, each of which must be satisfied by the corresponding item in an examined array */ @@ -674,7 +674,7 @@ public staticorg.hamcrest.Matcher arrayContaining(java.util.List * assertThat(new String[]{"foo", "bar"}, arrayContainingInAnyOrder(equalTo("bar"), equalTo("foo")))- * + * * @param itemMatchers * a list of matchers, each of which must be satisfied by an entry in an examined array */ @@ -699,7 +699,7 @@ public staticorg.hamcrest.Matcher arrayContainingInAnyOrder(org.hamcre * For example: * * assertThat(new String[]{"foo", "bar"}, arrayContainingInAnyOrder(Arrays.asList(equalTo("bar"), equalTo("foo"))))- * + * * @param itemMatchers * a list of matchers, each of which must be satisfied by an item provided by an examined array */ @@ -721,7 +721,7 @@ public staticorg.hamcrest.Matcher arrayContainingInAnyOrder(java.util. * For example: * * assertThat(new String[]{"foo", "bar"}, arrayContainingInAnyOrder("bar", "foo"))- * + * * @param items * the items that must equal the entries of an examined array, in any order */ @@ -735,7 +735,7 @@ public staticorg.hamcrest.Matcher arrayContainingInAnyOrder(E... items * satisfies the specified matcher. * For example: * assertThat(new String[]{"foo", "bar"}, arrayWithSize(equalTo(2)))- * + * * @param sizeMatcher * a matcher for the length of an examined array */ @@ -748,7 +748,7 @@ public staticorg.hamcrest.Matcher arrayWithSize(org.hamcrest.Matcher * equals the specified size
. * For example: *assertThat(new String[]{"foo", "bar"}, arrayWithSize(2))- * + * * @param size * the length that an examined array must have for a positive match */ @@ -771,11 +771,11 @@ public staticorg.hamcrest.Matcher emptyArray() { * a value that satisfies the specified matcher. * For example: * assertThat(myMap, is(aMapWithSize(equalTo(2))))- * + * * @param sizeMatcher * a matcher for the size of an examined {@link java.util.Map} */ - public staticorg.hamcrest.Matcher > aMapWithSize(org.hamcrest.Matcher super java.lang.Integer> sizeMatcher) { + public static org.hamcrest.Matcher > aMapWithSize(org.hamcrest.Matcher super java.lang.Integer> sizeMatcher) { return org.hamcrest.collection.IsMapWithSize.aMapWithSize(sizeMatcher); } @@ -784,11 +784,11 @@ public static org.hamcrest.Matcher * a value equal to the specified size
. * For example: *assertThat(myMap, is(aMapWithSize(2)))- * + * * @param size * the expected size of an examined {@link java.util.Map} */ - public staticorg.hamcrest.Matcher > aMapWithSize(int size) { + public static org.hamcrest.Matcher > aMapWithSize(int size) { return org.hamcrest.collection.IsMapWithSize.aMapWithSize(size); } @@ -798,7 +798,7 @@ public static org.hamcrest.Matcher * For example: * assertThat(myMap, is(anEmptyMap()))*/ - public staticorg.hamcrest.Matcher > anEmptyMap() { + public static org.hamcrest.Matcher > anEmptyMap() { return org.hamcrest.collection.IsMapWithSize.anEmptyMap(); } @@ -807,7 +807,7 @@ public static org.hamcrest.Matcher * a value that satisfies the specified matcher. * For example: * assertThat(Arrays.asList("foo", "bar"), hasSize(equalTo(2)))- * + * * @param sizeMatcher * a matcher for the size of an examined {@link java.util.Collection} */ @@ -820,7 +820,7 @@ public staticorg.hamcrest.Matcher > hasSiz * a value equal to the specified size
. * For example: *assertThat(Arrays.asList("foo", "bar"), hasSize(2))- * + * * @param size * the expected size of an examined {@link java.util.Collection} */ @@ -843,7 +843,7 @@ public staticorg.hamcrest.Matcher > empty( * method returns true
. * For example: *assertThat(new ArrayList<String>(), is(emptyCollectionOf(String.class)))- * + * * @param unusedToForceReturnType * the type of the collection's content */ @@ -864,7 +864,7 @@ public staticorg.hamcrest.Matcher > emptyIte * Creates a matcher for {@link Iterable}s matching examined iterables that yield no items. * For example: * assertThat(new ArrayList<String>(), is(emptyIterableOf(String.class)))- * + * * @param unusedToForceReturnType * the type of the iterable's content */ @@ -879,7 +879,7 @@ public staticorg.hamcrest.Matcher > emptyIterableOf(ja * must be of the same length as the number of specified items. * For example: * assertThat(Arrays.asList("foo", "bar"), contains("foo", "bar"))- * + * * @param items * the items that must equal the items provided by an examined {@link Iterable} */ @@ -894,10 +894,10 @@ public staticorg.hamcrest.Matcher > contains * For a positive match, the examined iterable must only yield one item. * For example: * assertThat(Arrays.asList("foo"), contains(equalTo("foo")))- * + * * @param itemMatcher * the matcher that must be satisfied by the single item provided by an - * examined {@link Iterable} + * examined {@link Iterable} */ public staticorg.hamcrest.Matcher > contains(org.hamcrest.Matcher super E> itemMatcher) { return org.hamcrest.collection.IsIterableContainingInOrder.contains(itemMatcher); @@ -910,7 +910,7 @@ public static org.hamcrest.Matcher > contains * must be of the same length as the number of specified matchers. * For example: * assertThat(Arrays.asList("foo", "bar"), contains(equalTo("foo"), equalTo("bar")))- * + * * @param itemMatchers * the matchers that must be satisfied by the items provided by an examined {@link Iterable} */ @@ -926,10 +926,10 @@ public staticorg.hamcrest.Matcher > contains * must be of the same length as the specified list of matchers. * For example: * assertThat(Arrays.asList("foo", "bar"), contains(Arrays.asList(equalTo("foo"), equalTo("bar"))))- * + * * @param itemMatchers * a list of matchers, each of which must be satisfied by the corresponding item provided by - * an examined {@link Iterable} + * an examined {@link Iterable} */ public staticorg.hamcrest.Matcher > contains(java.util.List > itemMatchers) { return org.hamcrest.collection.IsIterableContainingInOrder.contains(itemMatchers); @@ -951,7 +951,7 @@ public static org.hamcrest.Matcher > contains * For example: * * assertThat(Arrays.asList("foo", "bar"), containsInAnyOrder(equalTo("bar"), equalTo("foo")))- * + * * @param itemMatchers * a list of matchers, each of which must be satisfied by an item provided by an examined {@link Iterable} */ @@ -976,7 +976,7 @@ public staticorg.hamcrest.Matcher > contains * For example: * * assertThat(Arrays.asList("foo", "bar"), containsInAnyOrder("bar", "foo"))- * + * * @param items * the items that must equal the items provided by an examined {@link Iterable} in any order */ @@ -999,7 +999,7 @@ public staticorg.hamcrest.Matcher > contains * * For example:
*assertThat(Arrays.asList("foo", "bar"), containsInAnyOrder(Arrays.asList(equalTo("bar"), equalTo("foo"))))- * + * * @param itemMatchers * a list of matchers, each of which must be satisfied by an item provided by an examined {@link Iterable} */ @@ -1013,7 +1013,7 @@ public staticorg.hamcrest.Matcher > contains * corresponding item in the specified items, in the same relative order * For example: * assertThat(Arrays.asList("a", "b", "c", "d", "e"), containsInRelativeOrder("b", "d"))- * + * * @param items * the items that must be contained within items provided by an examined {@link Iterable} in the same relative order */ @@ -1028,7 +1028,7 @@ public staticorg.hamcrest.Matcher > contains * matcher in the specified matchers, in the same relative order. * For example: * assertThat(Arrays.asList("a", "b", "c", "d", "e"), containsInRelativeOrder(equalTo("b"), equalTo("d")))- * + * * @param itemMatchers * the matchers that must be satisfied by the items provided by an examined {@link Iterable} in the same relative order */ @@ -1043,10 +1043,10 @@ public staticorg.hamcrest.Matcher > contains * matcher in the specified list of matchers, in the same relative order. * For example: * assertThat(Arrays.asList("a", "b", "c", "d", "e"), contains(Arrays.asList(equalTo("b"), equalTo("d"))))- * + * * @param itemMatchers * a list of matchers, each of which must be satisfied by the items provided by - * an examined {@link Iterable} in the same relative order + * an examined {@link Iterable} in the same relative order */ public staticorg.hamcrest.Matcher > containsInRelativeOrder(java.util.List > itemMatchers) { return org.hamcrest.collection.IsIterableContainingInRelativeOrder.containsInRelativeOrder(itemMatchers); @@ -1058,7 +1058,7 @@ public static org.hamcrest.Matcher > contains * matcher. * For example: * assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))- * + * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ @@ -1072,7 +1072,7 @@ public staticorg.hamcrest.Matcher > iterableWithSize(o * size
argument. * For example: *assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))- * + * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ @@ -1086,13 +1086,13 @@ public staticorg.hamcrest.Matcher > iterableWithSize(i * value satisfies the specified valueMatcher
. * For example: *assertThat(myMap, hasEntry(equalTo("bar"), equalTo("foo")))- * + * * @param keyMatcher * the key matcher that, in combination with the valueMatcher, must be satisfied by at least one entry * @param valueMatcher * the value matcher that, in combination with the keyMatcher, must be satisfied by at least one entry */ - public staticorg.hamcrest.Matcher > hasEntry(org.hamcrest.Matcher super K> keyMatcher, org.hamcrest.Matcher super V> valueMatcher) { + public static org.hamcrest.Matcher > hasEntry(org.hamcrest.Matcher super K> keyMatcher, org.hamcrest.Matcher super V> valueMatcher) { return org.hamcrest.collection.IsMapContaining.hasEntry(keyMatcher, valueMatcher); } @@ -1102,13 +1102,13 @@ public static org.hamcrest.Matcher * specified value
. * For example: *assertThat(myMap, hasEntry("bar", "foo"))- * + * * @param key * the key that, in combination with the value, must be describe at least one entry * @param value * the value that, in combination with the key, must be describe at least one entry */ - public staticorg.hamcrest.Matcher > hasEntry(K key, V value) { + public static org.hamcrest.Matcher > hasEntry(K key, V value) { return org.hamcrest.collection.IsMapContaining.hasEntry(key, value); } @@ -1117,11 +1117,11 @@ public static org.hamcrest.Matcher * at least one key that satisfies the specified matcher. * For example: * assertThat(myMap, hasKey(equalTo("bar")))- * + * * @param keyMatcher * the matcher that must be satisfied by at least one key */ - public staticorg.hamcrest.Matcher > hasKey(org.hamcrest.Matcher super K> keyMatcher) { + public static org.hamcrest.Matcher > hasKey(org.hamcrest.Matcher super K> keyMatcher) { return org.hamcrest.collection.IsMapContaining.hasKey(keyMatcher); } @@ -1130,11 +1130,11 @@ public static org.hamcrest.Matcher > hasKey(org. * at least one key that is equal to the specified key. * For example: * assertThat(myMap, hasKey("bar"))- * + * * @param key * the key that satisfying maps must contain */ - public staticorg.hamcrest.Matcher > hasKey(K key) { + public static org.hamcrest.Matcher > hasKey(K key) { return org.hamcrest.collection.IsMapContaining.hasKey(key); } @@ -1143,11 +1143,11 @@ public static org.hamcrest.Matcher > hasKey(K ke * at least one value that satisfies the specified valueMatcher. * For example: * assertThat(myMap, hasValue(equalTo("foo")))- * + * * @param valueMatcher * the matcher that must be satisfied by at least one value */ - public staticorg.hamcrest.Matcher > hasValue(org.hamcrest.Matcher super V> valueMatcher) { + public static org.hamcrest.Matcher > hasValue(org.hamcrest.Matcher super V> valueMatcher) { return org.hamcrest.collection.IsMapContaining.hasValue(valueMatcher); } @@ -1156,11 +1156,11 @@ public static org.hamcrest.Matcher > hasValue(or * at least one value that is equal to the specified value. * For example: * assertThat(myMap, hasValue("foo"))- * + * * @param value * the value that satisfying maps must contain */ - public staticorg.hamcrest.Matcher > hasValue(V value) { + public static org.hamcrest.Matcher > hasValue(V value) { return org.hamcrest.collection.IsMapContaining.hasValue(value); } @@ -1169,7 +1169,7 @@ public static org.hamcrest.Matcher > hasValue(V * specified collection. * For example: * assertThat("foo", is(in(Arrays.asList("bar", "foo"))))- * + * * @param collection * the collection in which matching items must be found */ @@ -1182,7 +1182,7 @@ public staticorg.hamcrest.Matcher in(java.util.Collection collection) * specified array. * For example: * assertThat("foo", is(in(new String[]{"bar", "foo"})))- * + * * @param elements * the array in which matching items must be found */ @@ -1195,7 +1195,7 @@ public staticorg.hamcrest.Matcher in(T[] elements) { * specified collection. * For example: * assertThat("foo", isIn(Arrays.asList("bar", "foo")))- * + * * @deprecated use is(in(...)) instead * @param collection * the collection in which matching items must be found @@ -1210,7 +1210,7 @@ public staticorg.hamcrest.Matcher isIn(java.util.Collection collectio * specified array. * For example: * assertThat("foo", isIn(new String[]{"bar", "foo"}))- * + * * @deprecated use is(in(...)) instead * @param elements * the array in which matching items must be found @@ -1225,7 +1225,7 @@ public staticorg.hamcrest.Matcher isIn(T[] elements) { * specified elements. * For example: * assertThat("foo", isOneOf("bar", "foo"))- * + * * @deprecated use is(oneOf(...)) instead * @param elements * the elements amongst which matching items will be found @@ -1241,7 +1241,7 @@ public staticorg.hamcrest.Matcher isOneOf(T... elements) { * specified elements. * For example: * assertThat("foo", is(oneOf("bar", "foo")))- * + * * @param elements * the elements amongst which matching items will be found */ @@ -1255,7 +1255,7 @@ public staticorg.hamcrest.Matcher oneOf(T... elements) { * to the specified operand
, within a range of +/-error
. * For example: *assertThat(1.03, is(closeTo(1.0, 0.03)))- * + * * @param operand * the expected value of matching doubles * @param error @@ -1280,7 +1280,7 @@ public static org.hamcrest.MatchernotANumber() { * is done by BigDecimals {@link java.math.BigDecimal#compareTo(java.math.BigDecimal)} method. * For example: * assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))- * + * * @param operand * the expected value of matching BigDecimals * @param error @@ -1296,7 +1296,7 @@ public static org.hamcrest.MatchercloseTo(java.math.BigDe * examined object. * For example: * assertThat(1, comparesEqualTo(1))- * + * * @param value the value which, when passed to the compareTo method of the examined object, should return zero */ public static> org.hamcrest.Matcher comparesEqualTo(T value) { @@ -1309,7 +1309,7 @@ public static > org.hamcrest.Matcher compar * examined object. * For example: * assertThat(2, greaterThan(1))- * + * * @param value the value which, when passed to the compareTo method of the examined object, should return greater * than zero */ @@ -1323,7 +1323,7 @@ public static> org.hamcrest.Matcher greate * of the examined object. * For example: * assertThat(1, greaterThanOrEqualTo(1))- * + * * @param value the value which, when passed to the compareTo method of the examined object, should return greater * than or equal to zero */ @@ -1337,7 +1337,7 @@ public static> org.hamcrest.Matcher greate * examined object. * For example: * assertThat(1, lessThan(2))- * + * * @param value the value which, when passed to the compareTo method of the examined object, should return less * than zero */ @@ -1351,7 +1351,7 @@ public static> org.hamcrest.Matcher lessTh * of the examined object. * For example: * assertThat(1, lessThanOrEqualTo(1))- * + * * @param value the value which, when passed to the compareTo method of the examined object, should return less * than or equal to zero */ @@ -1364,7 +1364,7 @@ public static> org.hamcrest.Matcher lessTh * the specified expectedString, ignoring case. * For example: * assertThat("Foo", equalToIgnoringCase("FOO"))- * + * * @param expectedString * the expected value of matched strings */ @@ -1423,7 +1423,7 @@ public static MatcheremptyString() { * has zero length. * For example: * assertThat(((String)null), isEmptyOrNullString())- * + * * @deprecated use is(emptyOrNullString()) instead */ @SuppressWarnings("deprecation") @@ -1435,7 +1435,7 @@ public static MatcherisEmptyOrNullString() { * Creates a matcher of {@link String} that matches when the examined string has zero length. * For example: * assertThat("", isEmptyString())- * + * * @deprecated use is(emptyString()) instead */ @SuppressWarnings("deprecation") @@ -1485,7 +1485,7 @@ public static MatchermatchesPattern(java.lang.String regex) { * For example: * assertThat("myfoobarbaz", stringContainsInOrder(Arrays.asList("bar", "foo")))* fails as "foo" occurs before "bar" in the string "myfoobarbaz" - * + * * @param substrings * the substrings that must be contained within matching strings */ @@ -1499,7 +1499,7 @@ public static MatcherstringContainsInOrder(java.lang.Iterable * For example: * assertThat("myfoobarbaz", stringContainsInOrder("bar", "foo"))* fails as "foo" occurs before "bar" in the string "myfoobarbaz" - * + * * @param substrings * the substrings that must be contained within matching strings */ @@ -1507,27 +1507,27 @@ public static MatcherstringContainsInOrder(java.lang.String.. return org.hamcrest.text.StringContainsInOrder.stringContainsInOrder(substrings); } - /** - * Creates a matcher of {@link CharSequence} that matches when a char sequence has the length - * of the specified argument
. - * For example: - * - *- * assertThat("text", length(4)) - *- * - * @param length the expected length of the string - */ - public static MatcherhasLength(int length) { - return org.hamcrest.text.CharSequenceLength.hasLength(length); - } + /** + * Creates a matcher of {@link CharSequence} that matches when a char sequence has the length + * of the specified argument
. + * For example: + * + *+ * assertThat("text", length(4)) + *+ * + * @param length the expected length of the string + */ + public static MatcherhasLength(int length) { + return org.hamcrest.text.CharSequenceLength.hasLength(length); + } /** * Creates a matcher that matches any examined object whose toString
method * returns a value that satisfies the specified matcher. * For example: *assertThat(true, hasToString(equalTo("TRUE")))- * + * * @param toStringMatcher * the matcher used to verify the toString result */ @@ -1540,7 +1540,7 @@ public staticorg.hamcrest.Matcher hasToString(org.hamcrest.Matcher sup * returns a value equalTo the specified string. * For example: * assertThat(true, hasToString("TRUE"))- * + * * @param expectedToString * the expected toString result */ @@ -1553,7 +1553,7 @@ public staticorg.hamcrest.Matcher hasToString(java.lang.String expectedT * assignable from the examined class. * For example: * assertThat(Integer.class, typeCompatibleWith(Number.class))- * + * * @param baseType * the base class to examine classes against */ @@ -1566,7 +1566,7 @@ public staticorg.hamcrest.Matcher > typeCompatibleWith(ja * derived from eventClass announced by source. * For example: * assertThat(myEvent, is(eventFrom(PropertyChangeEvent.class, myBean)))- * + * * @param eventClass * the class of the event to match on * @param source @@ -1581,7 +1581,7 @@ public static org.hamcrest.MatchereventFrom(java.lang.Cl * announced by source. * For example: * assertThat(myEvent, is(eventFrom(myBean)))- * + * * @param source * the source of the event */ @@ -1594,7 +1594,7 @@ public static org.hamcrest.MatchereventFrom(java.lang.Ob * with the specified name. * For example: * assertThat(myBean, hasProperty("foo"))- * + * * @param propertyName * the name of the JavaBean property that examined beans should possess */ @@ -1607,7 +1607,7 @@ public staticorg.hamcrest.Matcher hasProperty(java.lang.String propertyN * with the specified name whose value satisfies the specified matcher. * For example: * assertThat(myBean, hasProperty("foo", equalTo("bar"))- * + * * @param propertyName * the name of the JavaBean property that examined beans should possess * @param valueMatcher @@ -1641,7 +1641,7 @@ public static Matcher samePropertyValuesAs(B expectedBean, String... igno * specified