From c2a42aa25bda80c9c2af8ba3238f90a23632a404 Mon Sep 17 00:00:00 2001
From: JJ Brown
Date: Sun, 19 Apr 2020 21:49:03 -0500
Subject: [PATCH] Enforced indentation style of 2 spaces (with further details
matching Google's CheckStyle specs).
Formatted existing .java code to match.
See #295
---
checkstyle.xml | 13 +
.../deprecated/HamcrestCoreIsDeprecated.java | 3 +-
.../java/org/hamcrest/EasyMock2Matchers.java | 13 +-
.../java/org/hamcrest/JMock1Matchers.java | 10 +-
.../org/hamcrest/JavaLangMatcherAssert.java | 16 +-
.../integration/EasyMock2Adapter.java | 53 +-
.../hamcrest/integration/JMock1Adapter.java | 49 +-
.../HamcrestLibraryIsDeprecated.java | 3 +-
.../java/org/hamcrest/BaseDescription.java | 283 ++++----
.../main/java/org/hamcrest/BaseMatcher.java | 67 +-
.../src/main/java/org/hamcrest/Condition.java | 113 ++--
.../main/java/org/hamcrest/CoreMatchers.java | 164 +++--
.../main/java/org/hamcrest/CustomMatcher.java | 31 +-
.../org/hamcrest/CustomTypeSafeMatcher.java | 29 +-
.../main/java/org/hamcrest/Description.java | 133 ++--
.../java/org/hamcrest/DiagnosingMatcher.java | 25 +-
.../java/org/hamcrest/FeatureMatcher.java | 47 +-
.../src/main/java/org/hamcrest/Matcher.java | 80 +--
.../main/java/org/hamcrest/MatcherAssert.java | 52 +-
.../src/main/java/org/hamcrest/Matchers.java | 633 +++++++++++-------
.../java/org/hamcrest/SelfDescribing.java | 21 +-
.../java/org/hamcrest/StringDescription.java | 107 +--
.../hamcrest/TypeSafeDiagnosingMatcher.java | 114 ++--
.../java/org/hamcrest/TypeSafeMatcher.java | 151 +++--
.../java/org/hamcrest/beans/HasProperty.java | 73 +-
.../hamcrest/beans/HasPropertyWithValue.java | 259 +++----
.../java/org/hamcrest/beans/PropertyUtil.java | 74 +-
.../hamcrest/beans/SamePropertyValuesAs.java | 279 ++++----
.../collection/ArrayAsIterableMatcher.java | 24 +-
.../hamcrest/collection/ArrayMatching.java | 48 +-
.../hamcrest/collection/HasItemInArray.java | 51 +-
.../java/org/hamcrest/collection/IsArray.java | 169 ++---
.../IsArrayContainingInAnyOrder.java | 182 ++---
.../collection/IsArrayContainingInOrder.java | 148 ++--
.../hamcrest/collection/IsArrayWithSize.java | 89 +--
.../collection/IsCollectionWithSize.java | 77 ++-
.../collection/IsEmptyCollection.java | 87 +--
.../hamcrest/collection/IsEmptyIterable.java | 74 +-
.../java/org/hamcrest/collection/IsIn.java | 230 +++----
.../IsIterableContainingInAnyOrder.java | 267 ++++----
.../IsIterableContainingInOrder.java | 268 ++++----
.../IsIterableContainingInRelativeOrder.java | 210 +++---
.../collection/IsIterableWithSize.java | 90 +--
.../hamcrest/collection/IsMapContaining.java | 225 ++++---
.../hamcrest/collection/IsMapWithSize.java | 99 +--
.../comparator/ComparatorMatcherBuilder.java | 336 +++++-----
.../main/java/org/hamcrest/core/AllOf.java | 89 +--
.../main/java/org/hamcrest/core/AnyOf.java | 85 +--
.../org/hamcrest/core/CombinableMatcher.java | 60 +-
.../java/org/hamcrest/core/DescribedAs.java | 110 +--
.../main/java/org/hamcrest/core/Every.java | 71 +-
.../src/main/java/org/hamcrest/core/Is.java | 111 +--
.../java/org/hamcrest/core/IsAnything.java | 83 ++-
.../hamcrest/core/IsCollectionContaining.java | 168 ++---
.../main/java/org/hamcrest/core/IsEqual.java | 154 +++--
.../java/org/hamcrest/core/IsInstanceOf.java | 172 +++--
.../hamcrest/core/IsIterableContaining.java | 230 ++++---
.../main/java/org/hamcrest/core/IsNot.java | 94 +--
.../main/java/org/hamcrest/core/IsNull.java | 116 ++--
.../main/java/org/hamcrest/core/IsSame.java | 86 +--
.../hamcrest/core/ShortcutCombination.java | 52 +-
.../org/hamcrest/core/StringContains.java | 76 ++-
.../org/hamcrest/core/StringEndsWith.java | 72 +-
.../core/StringRegularExpression.java | 22 +-
.../org/hamcrest/core/StringStartsWith.java | 74 +-
.../org/hamcrest/core/SubstringMatcher.java | 86 ++-
.../org/hamcrest/internal/ArrayIterator.java | 52 +-
.../org/hamcrest/internal/NullSafety.java | 19 +-
.../internal/ReflectiveTypeFinder.java | 66 +-
.../internal/SelfDescribingValue.java | 23 +-
.../internal/SelfDescribingValueIterator.java | 43 +-
.../java/org/hamcrest/io/FileMatchers.java | 224 ++++---
.../hamcrest/number/BigDecimalCloseTo.java | 51 +-
.../java/org/hamcrest/number/IsCloseTo.java | 105 +--
.../main/java/org/hamcrest/number/IsNaN.java | 61 +-
.../hamcrest/number/OrderingComparison.java | 146 ++--
.../org/hamcrest/object/HasEqualValues.java | 130 ++--
.../java/org/hamcrest/object/HasToString.java | 71 +-
.../org/hamcrest/object/IsCompatibleType.java | 74 +-
.../java/org/hamcrest/object/IsEventFrom.java | 119 ++--
.../org/hamcrest/text/CharSequenceLength.java | 94 +--
.../java/org/hamcrest/text/IsBlankString.java | 84 +--
.../java/org/hamcrest/text/IsEmptyString.java | 118 ++--
.../text/IsEqualCompressingWhiteSpace.java | 115 ++--
.../hamcrest/text/IsEqualIgnoringCase.java | 85 +--
.../org/hamcrest/text/MatchesPattern.java | 70 +-
.../hamcrest/text/StringContainsInOrder.java | 123 ++--
.../main/java/org/hamcrest/xml/HasXPath.java | 305 +++++----
.../org/hamcrest/AbstractMatcherTest.java | 85 ++-
.../org/hamcrest/BaseDescriptionTest.java | 226 ++++---
.../java/org/hamcrest/BaseMatcherTest.java | 37 +-
.../java/org/hamcrest/CustomMatcherTest.java | 26 +-
.../hamcrest/CustomTypeSafeMatcherTest.java | 70 +-
.../java/org/hamcrest/FeatureMatcherTest.java | 111 +--
.../java/org/hamcrest/MatcherAssertTest.java | 54 +-
.../org/hamcrest/NullDescriptionTest.java | 16 +-
.../TypeSafeDiagnosingMatcherTest.java | 134 ++--
.../org/hamcrest/TypeSafeMatcherTest.java | 29 +-
.../org/hamcrest/beans/HasPropertyTest.java | 70 +-
.../beans/HasPropertyWithValueTest.java | 155 +++--
.../beans/SamePropertyValuesAsTest.java | 116 ++--
.../ArrayMatchingInAnyOrderTest.java | 74 +-
.../collection/ArrayMatchingInOrderTest.java | 79 ++-
.../collection/HasItemInArrayTest.java | 122 ++--
.../IsArrayContainingInAnyOrderTest.java | 74 +-
.../IsArrayContainingInOrderTest.java | 70 +-
.../org/hamcrest/collection/IsArrayTest.java | 113 ++--
.../collection/IsArrayWithSizeTest.java | 58 +-
.../collection/IsCollectionWithSizeTest.java | 116 ++--
.../collection/IsEmptyCollectionTest.java | 74 +-
.../collection/IsEmptyIterableTest.java | 74 +-
.../org/hamcrest/collection/IsInTest.java | 73 +-
.../IsIterableContainingInAnyOrderTest.java | 42 +-
.../IsIterableContainingInOrderTest.java | 142 ++--
...IterableContainingInRelativeOrderTest.java | 190 +++---
.../collection/IsIterableWithSizeTest.java | 21 +-
.../collection/IsMapContainingKeyTest.java | 77 ++-
.../collection/IsMapContainingTest.java | 76 ++-
.../collection/IsMapContainingValueTest.java | 72 +-
.../collection/IsMapWithSizeTest.java | 130 ++--
.../ComparatorMatcherBuilderTest.java | 237 ++++---
.../comparator/ComparatorMatcherTest.java | 158 +++--
.../java/org/hamcrest/core/AllOfTest.java | 108 +--
.../java/org/hamcrest/core/AnyOfTest.java | 105 +--
.../org/hamcrest/core/CombinableTest.java | 107 +--
.../org/hamcrest/core/DescribedAsTest.java | 82 +--
.../java/org/hamcrest/core/EveryTest.java | 66 +-
.../org/hamcrest/core/IsAnythingTest.java | 68 +-
.../core/IsCollectionContainingTest.java | 175 ++---
.../java/org/hamcrest/core/IsEqualTest.java | 311 +++++----
.../org/hamcrest/core/IsInstanceOfTest.java | 103 +--
.../core/IsIterableContainingTest.java | 191 +++---
.../java/org/hamcrest/core/IsNotTest.java | 67 +-
.../java/org/hamcrest/core/IsNullTest.java | 69 +-
.../java/org/hamcrest/core/IsSameTest.java | 80 ++-
.../test/java/org/hamcrest/core/IsTest.java | 86 +--
.../org/hamcrest/core/SampleBaseClass.java | 39 +-
.../org/hamcrest/core/SampleSubClass.java | 12 +-
.../org/hamcrest/core/StringContainsTest.java | 70 +-
.../org/hamcrest/core/StringEndsWithTest.java | 72 +-
.../org/hamcrest/core/StringMatchingTest.java | 12 +-
.../core/StringRegularExpressionTest.java | 11 +-
.../hamcrest/core/StringStartsWithTest.java | 74 +-
.../org/hamcrest/io/FileMatchersTest.java | 168 ++---
.../number/BigDecimalCloseToTest.java | 19 +-
.../org/hamcrest/number/IsCloseToTest.java | 44 +-
.../java/org/hamcrest/number/IsNanTest.java | 75 ++-
.../number/OrderingComparisonTest.java | 145 ++--
.../hamcrest/object/HasEqualsValuesTest.java | 86 +--
.../org/hamcrest/object/HasToStringTest.java | 96 +--
.../hamcrest/object/IsCompatibleTypeTest.java | 79 ++-
.../org/hamcrest/object/IsEventFromTest.java | 84 +--
.../hamcrest/object/MatchesPatternTest.java | 103 +--
.../hamcrest/text/CharSequenceLengthTest.java | 52 +-
.../org/hamcrest/text/IsBlankStringTest.java | 98 +--
.../org/hamcrest/text/IsEmptyStringTest.java | 98 +--
.../IsEqualCompressingWhiteSpaceTest.java | 80 ++-
.../text/IsEqualIgnoringCaseTest.java | 114 ++--
.../text/StringContainsInOrderTest.java | 50 +-
.../java/org/hamcrest/xml/HasXPathTest.java | 247 +++----
160 files changed, 9169 insertions(+), 7336 deletions(-)
diff --git a/checkstyle.xml b/checkstyle.xml
index c1dbabf3..76b6a163 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -8,4 +8,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hamcrest-core/src/main/java/org/hamcrest/core/deprecated/HamcrestCoreIsDeprecated.java b/hamcrest-core/src/main/java/org/hamcrest/core/deprecated/HamcrestCoreIsDeprecated.java
index 19482c3d..0f87931a 100644
--- a/hamcrest-core/src/main/java/org/hamcrest/core/deprecated/HamcrestCoreIsDeprecated.java
+++ b/hamcrest-core/src/main/java/org/hamcrest/core/deprecated/HamcrestCoreIsDeprecated.java
@@ -5,5 +5,6 @@
* hamcrest.jar. Please use that dependency instead.
*/
@Deprecated
-class HamcrestCoreIsDeprecated {
+class HamcrestCoreIsDeprecated
+{
}
diff --git a/hamcrest-integration/src/main/java/org/hamcrest/EasyMock2Matchers.java b/hamcrest-integration/src/main/java/org/hamcrest/EasyMock2Matchers.java
index 936aa7d5..9e3dc1cb 100644
--- a/hamcrest-integration/src/main/java/org/hamcrest/EasyMock2Matchers.java
+++ b/hamcrest-integration/src/main/java/org/hamcrest/EasyMock2Matchers.java
@@ -4,14 +4,15 @@
import org.hamcrest.core.IsEqual;
/**
- *
* @author Joe Walnes
*/
-public class EasyMock2Matchers {
+public class EasyMock2Matchers
+{
- public static String equalTo(String string) {
- EasyMock2Adapter.adapt(IsEqual.equalTo(string));
- return null;
- }
+ public static String equalTo(String string)
+ {
+ EasyMock2Adapter.adapt(IsEqual.equalTo(string));
+ return null;
+ }
}
diff --git a/hamcrest-integration/src/main/java/org/hamcrest/JMock1Matchers.java b/hamcrest-integration/src/main/java/org/hamcrest/JMock1Matchers.java
index 6aac6f87..47c79fed 100644
--- a/hamcrest-integration/src/main/java/org/hamcrest/JMock1Matchers.java
+++ b/hamcrest-integration/src/main/java/org/hamcrest/JMock1Matchers.java
@@ -4,9 +4,11 @@
import org.hamcrest.core.IsEqual;
import org.jmock.core.Constraint;
-public class JMock1Matchers {
+public class JMock1Matchers
+{
- public static Constraint equalTo(String string) {
- return JMock1Adapter.adapt(IsEqual.equalTo(string));
- }
+ public static Constraint equalTo(String string)
+ {
+ return JMock1Adapter.adapt(IsEqual.equalTo(string));
+ }
}
diff --git a/hamcrest-integration/src/main/java/org/hamcrest/JavaLangMatcherAssert.java b/hamcrest-integration/src/main/java/org/hamcrest/JavaLangMatcherAssert.java
index 6cc97e81..68bb113c 100644
--- a/hamcrest-integration/src/main/java/org/hamcrest/JavaLangMatcherAssert.java
+++ b/hamcrest-integration/src/main/java/org/hamcrest/JavaLangMatcherAssert.java
@@ -9,10 +9,16 @@
*
* @author Neil Dunn
*/
-public class JavaLangMatcherAssert {
- private JavaLangMatcherAssert() {};
+public class JavaLangMatcherAssert
+{
+ private JavaLangMatcherAssert()
+ {
+ }
- public static boolean that(T argument, Matcher super T> matcher) {
- return matcher.matches(argument);
- }
+ ;
+
+ public static boolean that(T argument, Matcher super T> matcher)
+ {
+ return matcher.matches(argument);
+ }
}
diff --git a/hamcrest-integration/src/main/java/org/hamcrest/integration/EasyMock2Adapter.java b/hamcrest-integration/src/main/java/org/hamcrest/integration/EasyMock2Adapter.java
index 09ab0f7d..cc694a89 100644
--- a/hamcrest-integration/src/main/java/org/hamcrest/integration/EasyMock2Adapter.java
+++ b/hamcrest-integration/src/main/java/org/hamcrest/integration/EasyMock2Adapter.java
@@ -11,33 +11,38 @@
*
* @author Joe Walnes
*/
-public class EasyMock2Adapter implements IArgumentMatcher {
+public class EasyMock2Adapter implements IArgumentMatcher
+{
- /**
- * Convenience factory method that will adapt a
- * 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.
- */
- public static IArgumentMatcher adapt(Matcher> matcher) {
- EasyMock2Adapter easyMock2Matcher = new EasyMock2Adapter(matcher);
- EasyMock.reportMatcher(easyMock2Matcher);
- return easyMock2Matcher;
- }
+ /**
+ * Convenience factory method that will adapt a
+ * 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.
+ */
+ public static IArgumentMatcher adapt(Matcher> matcher)
+ {
+ EasyMock2Adapter easyMock2Matcher = new EasyMock2Adapter(matcher);
+ EasyMock.reportMatcher(easyMock2Matcher);
+ return easyMock2Matcher;
+ }
- private final Matcher> hamcrestMatcher;
+ private final Matcher> hamcrestMatcher;
- public EasyMock2Adapter(Matcher> matcher) {
- this.hamcrestMatcher = matcher;
- }
+ public EasyMock2Adapter(Matcher> matcher)
+ {
+ this.hamcrestMatcher = matcher;
+ }
- @Override
- public boolean matches(Object argument) {
- return hamcrestMatcher.matches(argument);
- }
+ @Override
+ public boolean matches(Object argument)
+ {
+ return hamcrestMatcher.matches(argument);
+ }
- @Override
- public void appendTo(StringBuffer buffer) {
- hamcrestMatcher.describeTo(new StringDescription(buffer));
- }
+ @Override
+ public void appendTo(StringBuffer buffer)
+ {
+ hamcrestMatcher.describeTo(new StringDescription(buffer));
+ }
}
diff --git a/hamcrest-integration/src/main/java/org/hamcrest/integration/JMock1Adapter.java b/hamcrest-integration/src/main/java/org/hamcrest/integration/JMock1Adapter.java
index fa2021ce..b8398c0f 100644
--- a/hamcrest-integration/src/main/java/org/hamcrest/integration/JMock1Adapter.java
+++ b/hamcrest-integration/src/main/java/org/hamcrest/integration/JMock1Adapter.java
@@ -12,31 +12,36 @@
*
* @author Joe Walnes
*/
-public class JMock1Adapter implements Constraint {
+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}.
- */
- public static Constraint adapt(Matcher> matcher) {
- return new JMock1Adapter(matcher);
- }
+ /**
+ * Convenience factory method that will adapt a
+ * Hamcrest {@link org.hamcrest.Matcher} to act as an
+ * jMock {@link org.jmock.core.Constraint}.
+ */
+ public static Constraint adapt(Matcher> matcher)
+ {
+ return new JMock1Adapter(matcher);
+ }
- private final Matcher> hamcrestMatcher;
+ private final Matcher> hamcrestMatcher;
- public JMock1Adapter(Matcher> matcher) {
- this.hamcrestMatcher = matcher;
- }
+ public JMock1Adapter(Matcher> matcher)
+ {
+ this.hamcrestMatcher = matcher;
+ }
- @Override
- public boolean eval(Object o) {
- return hamcrestMatcher.matches(o);
- }
+ @Override
+ public boolean eval(Object o)
+ {
+ return hamcrestMatcher.matches(o);
+ }
- @Override
- public StringBuffer describeTo(StringBuffer buffer) {
- hamcrestMatcher.describeTo(new StringDescription(buffer));
- return buffer;
- }
+ @Override
+ public StringBuffer describeTo(StringBuffer buffer)
+ {
+ hamcrestMatcher.describeTo(new StringDescription(buffer));
+ return buffer;
+ }
}
diff --git a/hamcrest-library/src/main/java/org/hamcrest/library/deprecated/HamcrestLibraryIsDeprecated.java b/hamcrest-library/src/main/java/org/hamcrest/library/deprecated/HamcrestLibraryIsDeprecated.java
index b7ec20c3..acce98ca 100644
--- a/hamcrest-library/src/main/java/org/hamcrest/library/deprecated/HamcrestLibraryIsDeprecated.java
+++ b/hamcrest-library/src/main/java/org/hamcrest/library/deprecated/HamcrestLibraryIsDeprecated.java
@@ -5,5 +5,6 @@
* hamcrest.jar. Please use that dependency instead.
*/
@Deprecated
-class HamcrestLibraryIsDeprecated {
+class HamcrestLibraryIsDeprecated
+{
}
diff --git a/hamcrest/src/main/java/org/hamcrest/BaseDescription.java b/hamcrest/src/main/java/org/hamcrest/BaseDescription.java
index d0c8fc41..b2a09073 100644
--- a/hamcrest/src/main/java/org/hamcrest/BaseDescription.java
+++ b/hamcrest/src/main/java/org/hamcrest/BaseDescription.java
@@ -11,142 +11,181 @@
/**
* A {@link Description} that is stored as a string.
*/
-public abstract class BaseDescription implements Description {
+public abstract class BaseDescription implements Description
+{
- @Override
- public Description appendText(String text) {
- append(text);
- return this;
+ @Override
+ public Description appendText(String text)
+ {
+ append(text);
+ return this;
+ }
+
+ @Override
+ public Description appendDescriptionOf(SelfDescribing value)
+ {
+ value.describeTo(this);
+ return this;
+ }
+
+ @Override
+ public Description appendValue(Object value)
+ {
+ if (value == null)
+ {
+ append("null");
}
-
- @Override
- public Description appendDescriptionOf(SelfDescribing value) {
- value.describeTo(this);
- return this;
+ else if (value instanceof String)
+ {
+ toJavaSyntax((String) value);
}
-
- @Override
- public Description appendValue(Object value) {
- if (value == null) {
- append("null");
- } else if (value instanceof String) {
- toJavaSyntax((String) value);
- } else if (value instanceof Character) {
- append('"');
- toJavaSyntax((Character) value);
- append('"');
- } else if (value instanceof Byte) {
- append('<');
- append(descriptionOf(value));
- append("b>");
- } else if (value instanceof Short) {
- append('<');
- append(descriptionOf(value));
- append("s>");
- } else if (value instanceof Long) {
- append('<');
- append(descriptionOf(value));
- append("L>");
- } else if (value instanceof Float) {
- append('<');
- append(descriptionOf(value));
- append("F>");
- } else if (value.getClass().isArray()) {
- appendValueList("[",", ","]", new ArrayIterator(value));
- } else {
- append('<');
- append(descriptionOf(value));
- append('>');
- }
- return this;
+ else if (value instanceof Character)
+ {
+ append('"');
+ toJavaSyntax((Character) value);
+ append('"');
}
-
- private String descriptionOf(Object value) {
- try {
- return valueOf(value);
- }
- catch (Exception e) {
- return value.getClass().getName() + "@" + Integer.toHexString(value.hashCode());
- }
+ else if (value instanceof Byte)
+ {
+ append('<');
+ append(descriptionOf(value));
+ append("b>");
}
-
- @SafeVarargs
- @Override
- public final Description appendValueList(String start, String separator, String end, T... values) {
- return appendValueList(start, separator, end, Arrays.asList(values));
+ else if (value instanceof Short)
+ {
+ append('<');
+ append(descriptionOf(value));
+ append("s>");
}
-
- @Override
- public Description appendValueList(String start, String separator, String end, Iterable values) {
- return appendValueList(start, separator, end, values.iterator());
+ else if (value instanceof Long)
+ {
+ append('<');
+ append(descriptionOf(value));
+ append("L>");
}
-
- private Description appendValueList(String start, String separator, String end, Iterator values) {
- return appendList(start, separator, end, new SelfDescribingValueIterator<>(values));
+ else if (value instanceof Float)
+ {
+ append('<');
+ append(descriptionOf(value));
+ append("F>");
+ }
+ else if (value.getClass().isArray())
+ {
+ appendValueList("[", ", ", "]", new ArrayIterator(value));
+ }
+ else
+ {
+ append('<');
+ append(descriptionOf(value));
+ append('>');
+ }
+ return this;
+ }
+
+ private String descriptionOf(Object value)
+ {
+ try
+ {
+ return valueOf(value);
}
-
- @Override
- public Description appendList(String start, String separator, String end, Iterable extends SelfDescribing> values) {
- return appendList(start, separator, end, values.iterator());
+ catch (Exception e)
+ {
+ return value.getClass().getName() + "@" + Integer.toHexString(value.hashCode());
}
+ }
- private Description appendList(String start, String separator, String end, Iterator extends SelfDescribing> i) {
- boolean separate = false;
-
- append(start);
- while (i.hasNext()) {
- if (separate) append(separator);
- appendDescriptionOf(i.next());
- separate = true;
- }
- append(end);
-
- return this;
+ @SafeVarargs
+ @Override
+ public final Description appendValueList(String start, String separator, String end, T... values)
+ {
+ return appendValueList(start, separator, end, Arrays.asList(values));
+ }
+
+ @Override
+ public Description appendValueList(String start, String separator, String end, Iterable values)
+ {
+ return appendValueList(start, separator, end, values.iterator());
+ }
+
+ private Description appendValueList(String start, String separator, String end, Iterator values)
+ {
+ return appendList(start, separator, end, new SelfDescribingValueIterator<>(values));
+ }
+
+ @Override
+ public Description appendList(String start, String separator, String end, Iterable extends SelfDescribing> values)
+ {
+ return appendList(start, separator, end, values.iterator());
+ }
+
+ private Description appendList(String start, String separator, String end, Iterator extends SelfDescribing> i)
+ {
+ boolean separate = false;
+
+ append(start);
+ while (i.hasNext())
+ {
+ if (separate)
+ {
+ append(separator);
+ }
+ appendDescriptionOf(i.next());
+ separate = true;
}
+ append(end);
+
+ return this;
+ }
- /**
- * Append the String str to the description.
- * The default implementation passes every character to {@link #append(char)}.
- * Override in subclasses to provide an efficient implementation.
- */
- protected void append(String str) {
- for (int i = 0; i < str.length(); i++) {
- append(str.charAt(i));
- }
+ /**
+ * Append the String str to the description.
+ * The default implementation passes every character to {@link #append(char)}.
+ * Override in subclasses to provide an efficient implementation.
+ */
+ protected void append(String str)
+ {
+ for (int i = 0; i < str.length(); i++)
+ {
+ append(str.charAt(i));
}
-
- /**
- * Append the char c to the description.
- */
- protected abstract void append(char c);
-
- private void toJavaSyntax(String unformatted) {
- append('"');
- for (int i = 0; i < unformatted.length(); i++) {
- toJavaSyntax(unformatted.charAt(i));
- }
- append('"');
+ }
+
+ /**
+ * Append the char c to the description.
+ */
+ protected abstract void append(char c);
+
+ private void toJavaSyntax(String unformatted)
+ {
+ append('"');
+ for (int i = 0; i < unformatted.length(); i++)
+ {
+ toJavaSyntax(unformatted.charAt(i));
}
+ append('"');
+ }
- private void toJavaSyntax(char ch) {
- switch (ch) {
- case '"':
- append("\\\"");
- break;
- case '\n':
- append("\\n");
- break;
- case '\r':
- append("\\r");
- break;
- case '\t':
- append("\\t");
- break;
- case '\\':
- append("\\\\");
- break;
- default:
- append(ch);
- }
+ private void toJavaSyntax(char ch)
+ {
+ switch (ch)
+ {
+ case '"':
+ append("\\\"");
+ break;
+ case '\n':
+ append("\\n");
+ break;
+ case '\r':
+ append("\\r");
+ break;
+ case '\t':
+ append("\\t");
+ break;
+ case '\\':
+ append("\\\\");
+ break;
+ default:
+ append(ch);
}
+ }
}
diff --git a/hamcrest/src/main/java/org/hamcrest/BaseMatcher.java b/hamcrest/src/main/java/org/hamcrest/BaseMatcher.java
index aaa6e957..d4c10b99 100644
--- a/hamcrest/src/main/java/org/hamcrest/BaseMatcher.java
+++ b/hamcrest/src/main/java/org/hamcrest/BaseMatcher.java
@@ -5,38 +5,47 @@
*
* @see Matcher
*/
-public abstract class BaseMatcher implements Matcher {
+public abstract class BaseMatcher implements Matcher
+{
- /**
- * @see Matcher#_dont_implement_Matcher___instead_extend_BaseMatcher_()
- */
- @Override
- @Deprecated
- public final void _dont_implement_Matcher___instead_extend_BaseMatcher_() {
- // See Matcher interface for an explanation of this method.
- }
+ /**
+ * @see Matcher#_dont_implement_Matcher___instead_extend_BaseMatcher_()
+ */
+ @Override
+ @Deprecated
+ public final void _dont_implement_Matcher___instead_extend_BaseMatcher_()
+ {
+ // See Matcher interface for an explanation of this method.
+ }
- @Override
- public void describeMismatch(Object item, Description description) {
- description.appendText("was ").appendValue(item);
- }
+ @Override
+ public void describeMismatch(Object item, Description description)
+ {
+ description.appendText("was ").appendValue(item);
+ }
- @Override
- public String toString() {
- return StringDescription.toString(this);
- }
+ @Override
+ public String toString()
+ {
+ return StringDescription.toString(this);
+ }
- /**
- * Useful null-check method. Writes a mismatch description if the actual object is null
- * @param actual the object to check
- * @param mismatch where to write the mismatch description, if any
- * @return false iff the actual object is null
- */
- protected static boolean isNotNull(Object actual, Description mismatch) {
- if (actual == null) {
- mismatch.appendText("was null");
- return false;
- }
- return true;
+ /**
+ * Useful null-check method. Writes a mismatch description if the actual object is null
+ *
+ * @param actual
+ * the object to check
+ * @param mismatch
+ * where to write the mismatch description, if any
+ * @return false iff the actual object is null
+ */
+ protected static boolean isNotNull(Object actual, Description mismatch)
+ {
+ if (actual == null)
+ {
+ mismatch.appendText("was null");
+ return false;
}
+ return true;
+ }
}
diff --git a/hamcrest/src/main/java/org/hamcrest/Condition.java b/hamcrest/src/main/java/org/hamcrest/Condition.java
index 02ce09e6..d1cdaba2 100644
--- a/hamcrest/src/main/java/org/hamcrest/Condition.java
+++ b/hamcrest/src/main/java/org/hamcrest/Condition.java
@@ -5,65 +5,90 @@
* that have a sequence of steps, where each step depends on the result of the previous
* step and we can stop processing as soon as a step fails. These classes provide
* infrastructure for writing such a sequence.
- *
+ *
* Based on https://github.com/npryce/maybe-java
+ *
* @author Steve Freeman 2012 http://www.hamcrest.com
*/
-public abstract class Condition {
- public static final NotMatched
*/
- public static org.hamcrest.Matcher equalTo(T operand) {
+ public static org.hamcrest.Matcher equalTo(T operand)
+ {
return org.hamcrest.core.IsEqual.equalTo(operand);
}
@@ -236,7 +255,8 @@ public static org.hamcrest.Matcher equalTo(T operand) {
* Creates an {@link org.hamcrest.core.IsEqual} matcher that does not enforce the values being
* compared to be of the same static type.
*/
- public static org.hamcrest.Matcher equalToObject(java.lang.Object operand) {
+ public static org.hamcrest.Matcher equalToObject(java.lang.Object operand)
+ {
return org.hamcrest.core.IsEqual.equalToObject(operand);
}
@@ -244,14 +264,15 @@ public static org.hamcrest.Matcher equalToObject(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
* with(any(Thing.class))
* For example:
*
assertThat(new Canoe(), instanceOf(Canoe.class));
*/
- public static org.hamcrest.Matcher any(java.lang.Class type) {
+ public static org.hamcrest.Matcher any(java.lang.Class type)
+ {
return org.hamcrest.core.IsInstanceOf.any(type);
}
@@ -259,12 +280,13 @@ public static 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.
*/
- public static org.hamcrest.Matcher instanceOf(java.lang.Class> type) {
+ public static org.hamcrest.Matcher instanceOf(java.lang.Class> type)
+ {
return org.hamcrest.core.IsInstanceOf.instanceOf(type);
}
@@ -273,11 +295,12 @@ public static org.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
*/
- public static org.hamcrest.Matcher not(org.hamcrest.Matcher matcher) {
+ public static org.hamcrest.Matcher not(org.hamcrest.Matcher matcher)
+ {
return org.hamcrest.core.IsNot.not(matcher);
}
@@ -287,11 +310,12 @@ public static org.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
*/
- public static org.hamcrest.Matcher not(T value) {
+ public static org.hamcrest.Matcher not(T value)
+ {
return org.hamcrest.core.IsNot.not(value);
}
@@ -302,7 +326,8 @@ public static org.hamcrest.Matcher not(T value) {
* instead of:
*
assertThat(cheese, is(not(nullValue())))
*/
- public static org.hamcrest.Matcher notNullValue() {
+ public static org.hamcrest.Matcher notNullValue()
+ {
return org.hamcrest.core.IsNull.notNullValue();
}
@@ -313,11 +338,12 @@ public static org.hamcrest.Matcher notNullValue() {
*
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
*/
- public static org.hamcrest.Matcher notNullValue(java.lang.Class type) {
+ public static org.hamcrest.Matcher notNullValue(java.lang.Class type)
+ {
return org.hamcrest.core.IsNull.notNullValue(type);
}
@@ -326,7 +352,8 @@ public static org.hamcrest.Matcher notNullValue(java.lang.Class type)
* For example:
*
assertThat(cheese, is(nullValue())
*/
- public static org.hamcrest.Matcher nullValue() {
+ public static org.hamcrest.Matcher nullValue()
+ {
return org.hamcrest.core.IsNull.nullValue();
}
@@ -335,33 +362,36 @@ public static org.hamcrest.Matcher nullValue() {
* 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
*/
- public static org.hamcrest.Matcher nullValue(java.lang.Class type) {
+ public static org.hamcrest.Matcher nullValue(java.lang.Class type)
+ {
return org.hamcrest.core.IsNull.nullValue(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
*/
- public static org.hamcrest.Matcher sameInstance(T target) {
+ public static org.hamcrest.Matcher sameInstance(T target)
+ {
return org.hamcrest.core.IsSame.sameInstance(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) {
+ public static org.hamcrest.Matcher theInstance(T target)
+ {
return org.hamcrest.core.IsSame.theInstance(target);
}
@@ -370,11 +400,12 @@ public static org.hamcrest.Matcher theInstance(T target) {
* {@link String} anywhere.
* For example:
*
- *
+ *
* @param substring
* the substring that the returned matcher will expect to find within any examined string
*/
- public static org.hamcrest.Matcher containsString(java.lang.String substring) {
+ public static org.hamcrest.Matcher containsString(java.lang.String substring)
+ {
return org.hamcrest.core.StringContains.containsString(substring);
}
@@ -383,11 +414,12 @@ public static org.hamcrest.Matcher containsString(java.lang.St
* {@link String} anywhere, ignoring case.
* For example:
*
- *
+ *
* @param substring
* the substring that the returned matcher will expect to find within any examined string
*/
- public static org.hamcrest.Matcher containsStringIgnoringCase(java.lang.String substring) {
+ public static org.hamcrest.Matcher containsStringIgnoringCase(java.lang.String substring)
+ {
return org.hamcrest.core.StringContains.containsStringIgnoringCase(substring);
}
@@ -398,11 +430,12 @@ public static org.hamcrest.Matcher containsStringIgnoringCase(
*
* For example:
*
assertThat("myStringOfNote", startsWith("my"))
- *
+ *
* @param prefix
- * the substring that the returned matcher will expect at the start of any examined string
+ * the substring that the returned matcher will expect at the start of any examined string
*/
- public static org.hamcrest.Matcher startsWith(java.lang.String prefix) {
+ public static org.hamcrest.Matcher startsWith(java.lang.String prefix)
+ {
return org.hamcrest.core.StringStartsWith.startsWith(prefix);
}
@@ -413,11 +446,12 @@ public static org.hamcrest.Matcher startsWith(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
+ * the substring that the returned matcher will expect at the start of any examined string
*/
- public static org.hamcrest.Matcher startsWithIgnoringCase(java.lang.String prefix) {
+ public static org.hamcrest.Matcher startsWithIgnoringCase(java.lang.String prefix)
+ {
return org.hamcrest.core.StringStartsWith.startsWithIgnoringCase(prefix);
}
@@ -426,11 +460,12 @@ public static org.hamcrest.Matcher startsWithIgnoringCase(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
+ * the substring that the returned matcher will expect at the end of any examined string
*/
- public static org.hamcrest.Matcher endsWith(java.lang.String suffix) {
+ public static org.hamcrest.Matcher endsWith(java.lang.String suffix)
+ {
return org.hamcrest.core.StringEndsWith.endsWith(suffix);
}
@@ -439,11 +474,12 @@ public static org.hamcrest.Matcher endsWith(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
+ * the substring that the returned matcher will expect at the end of any examined string
*/
- public static org.hamcrest.Matcher endsWithIgnoringCase(java.lang.String suffix) {
+ public static org.hamcrest.Matcher endsWithIgnoringCase(java.lang.String suffix)
+ {
return org.hamcrest.core.StringEndsWith.endsWithIgnoringCase(suffix);
}
diff --git a/hamcrest/src/main/java/org/hamcrest/CustomMatcher.java b/hamcrest/src/main/java/org/hamcrest/CustomMatcher.java
index 036a7640..fc128185 100644
--- a/hamcrest/src/main/java/org/hamcrest/CustomMatcher.java
+++ b/hamcrest/src/main/java/org/hamcrest/CustomMatcher.java
@@ -15,23 +15,28 @@
* matcher makes sense. It should not be used by API designers implementing
* matchers.
*
+ * @param
+ * The type of object being matched.
* @author Neil Dunn
* @see CustomTypeSafeMatcher for a type safe variant of this class that you probably
- * want to use.
- * @param The type of object being matched.
+ * want to use.
*/
-public abstract class CustomMatcher extends BaseMatcher {
- private final String fixedDescription;
+public abstract class CustomMatcher extends BaseMatcher
+{
+ 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..bd1d7173 100644
--- a/hamcrest/src/main/java/org/hamcrest/CustomTypeSafeMatcher.java
+++ b/hamcrest/src/main/java/org/hamcrest/CustomTypeSafeMatcher.java
@@ -19,21 +19,26 @@
* is called the argument is guaranteed to be non-null and of the correct
* type.
*
+ * @param
+ * The type of object being matched
* @author Neil Dunn
- * @param The type of object being matched
*/
-public abstract class CustomTypeSafeMatcher extends TypeSafeMatcher {
- private final String fixedDescription;
+public abstract class CustomTypeSafeMatcher extends TypeSafeMatcher
+{
+ 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..ce43e228 100644
--- a/hamcrest/src/main/java/org/hamcrest/Description.java
+++ b/hamcrest/src/main/java/org/hamcrest/Description.java
@@ -6,84 +6,93 @@
*
* @see Matcher#describeTo(Description)
*/
-public interface Description {
+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..515a6fe7 100644
--- a/hamcrest/src/main/java/org/hamcrest/DiagnosingMatcher.java
+++ b/hamcrest/src/main/java/org/hamcrest/DiagnosingMatcher.java
@@ -2,20 +2,21 @@
/**
* TODO(ngd): Document.
- *
- * @param
*/
-public abstract class DiagnosingMatcher extends BaseMatcher {
+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..90ef25ad 100644
--- a/hamcrest/src/main/java/org/hamcrest/FeatureMatcher.java
+++ b/hamcrest/src/main/java/org/hamcrest/FeatureMatcher.java
@@ -4,51 +4,64 @@
/**
* 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.
*
- * @param The type of the object to be matched
- * @param The type of the feature to be matched
+ * @param
+ * The 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);
+public abstract class FeatureMatcher extends TypeSafeDiagnosingMatcher
+{
+ 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 featureDescription Descriptive text to use in describeTo
- * @param featureName Identifying text for mismatch message
+ *
+ * @param subMatcher
+ * The matcher to apply to the feature
+ * @param featureDescription
+ * Descriptive text to use in describeTo
+ * @param featureName
+ * Identifying text for mismatch message
*/
- public FeatureMatcher(Matcher super U> subMatcher, String featureDescription, String featureName) {
+ public FeatureMatcher(Matcher super U> subMatcher, String featureDescription, String featureName)
+ {
super(TYPE_FINDER);
this.subMatcher = subMatcher;
this.featureDescription = featureDescription;
this.featureName = featureName;
}
-
+
/**
* Implement this to extract the interesting feature.
- * @param actual the target object
+ *
+ * @param actual
+ * the target object
* @return the feature to be matched
*/
protected abstract U featureValueOf(T actual);
@Override
- protected boolean matchesSafely(T actual, Description mismatch) {
+ protected boolean matchesSafely(T actual, Description mismatch)
+ {
final U featureValue = featureValueOf(actual);
- if (!subMatcher.matches(featureValue)) {
+ if (!subMatcher.matches(featureValue))
+ {
mismatch.appendText(featureName).appendText(" ");
subMatcher.describeMismatch(featureValue, mismatch);
return false;
}
return true;
}
-
+
@Override
- public final void describeTo(Description description) {
+ 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..86e1839a 100644
--- a/hamcrest/src/main/java/org/hamcrest/Matcher.java
+++ b/hamcrest/src/main/java/org/hamcrest/Matcher.java
@@ -23,45 +23,47 @@
*
* @see BaseMatcher
*/
-public interface Matcher extends SelfDescribing {
+public interface Matcher extends SelfDescribing
+{
- /**
- * 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, otherwise false.
- *
- * @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 that matches(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);
+ /**
+ * 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, otherwise false.
+ * @see BaseMatcher
+ */
+ boolean matches(Object actual);
- /**
- * 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_();
+ /**
+ * 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 that matches(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);
+
+ /**
+ * 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..bab5e5c5 100644
--- a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java
+++ b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java
@@ -1,29 +1,35 @@
package org.hamcrest;
-public class MatcherAssert {
- 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 class MatcherAssert
+{
+ 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..f97682fe 100644
--- a/hamcrest/src/main/java/org/hamcrest/Matchers.java
+++ b/hamcrest/src/main/java/org/hamcrest/Matchers.java
@@ -7,15 +7,17 @@
import java.util.regex.Pattern;
-@SuppressWarnings({"unused", "WeakerAccess"})
-public class Matchers {
+@SuppressWarnings({ "unused", "WeakerAccess" })
+public class Matchers
+{
/**
* Creates a matcher that matches if the examined object matches ALL of the specified matchers.
* For example:
*
*/
- public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third) {
+ public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third)
+ {
return org.hamcrest.core.AllOf.allOf(first, second, third);
}
@@ -52,7 +57,8 @@ public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T>
* For example:
*
*/
- public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth) {
+ public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth)
+ {
return org.hamcrest.core.AllOf.allOf(first, second, third, fourth);
}
@@ -61,7 +67,8 @@ public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T>
* For example:
*
*/
- public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth, org.hamcrest.Matcher super T> fifth) {
+ public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth, org.hamcrest.Matcher super T> fifth)
+ {
return org.hamcrest.core.AllOf.allOf(first, second, third, fourth, fifth);
}
@@ -70,7 +77,9 @@ public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T>
* For example:
*
*/
- public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth, org.hamcrest.Matcher super T> fifth, org.hamcrest.Matcher super T> sixth) {
+ public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth, org.hamcrest.Matcher super T> fifth,
+ org.hamcrest.Matcher super T> sixth)
+ {
return org.hamcrest.core.AllOf.allOf(first, second, third, fourth, fifth, sixth);
}
@@ -79,7 +88,8 @@ public static org.hamcrest.Matcher allOf(org.hamcrest.Matcher super T>
* For example:
*
*/
- public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second) {
+ public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second)
+ {
return org.hamcrest.core.AnyOf.anyOf(first, second);
}
@@ -107,7 +119,8 @@ public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super
* For example:
*
*/
- public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third) {
+ public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third)
+ {
return org.hamcrest.core.AnyOf.anyOf(first, second, third);
}
@@ -116,7 +129,8 @@ public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super
* For example:
*
*/
- public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth) {
+ public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth)
+ {
return org.hamcrest.core.AnyOf.anyOf(first, second, third, fourth);
}
@@ -125,7 +139,8 @@ public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super
* For example:
*
*/
- public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth, org.hamcrest.Matcher super T> fifth) {
+ public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth, org.hamcrest.Matcher super T> fifth)
+ {
return org.hamcrest.core.AnyOf.anyOf(first, second, third, fourth, fifth);
}
@@ -134,7 +149,9 @@ public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super
* For example:
*
*/
- public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth, org.hamcrest.Matcher super T> fifth, org.hamcrest.Matcher super T> sixth) {
+ public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super T> first, org.hamcrest.Matcher super T> second, org.hamcrest.Matcher super T> third, org.hamcrest.Matcher super T> fourth, org.hamcrest.Matcher super T> fifth,
+ org.hamcrest.Matcher super T> sixth)
+ {
return org.hamcrest.core.AnyOf.anyOf(first, second, third, fourth, fifth, sixth);
}
@@ -143,7 +160,8 @@ public static org.hamcrest.core.AnyOf anyOf(org.hamcrest.Matcher super
* For example:
*
*/
- public static org.hamcrest.core.CombinableMatcher.CombinableBothMatcher both(org.hamcrest.Matcher super LHS> matcher) {
+ public static org.hamcrest.core.CombinableMatcher.CombinableBothMatcher both(org.hamcrest.Matcher super LHS> matcher)
+ {
return org.hamcrest.core.CombinableMatcher.both(matcher);
}
@@ -152,7 +170,8 @@ public static org.hamcrest.core.CombinableMatcher.CombinableBothMatcherassertThat("fan", either(containsString("a")).or(containsString("b")))
*/
- public static org.hamcrest.core.CombinableMatcher.CombinableEitherMatcher either(org.hamcrest.Matcher super LHS> matcher) {
+ public static org.hamcrest.core.CombinableMatcher.CombinableEitherMatcher either(org.hamcrest.Matcher super LHS> matcher)
+ {
return org.hamcrest.core.CombinableMatcher.either(matcher);
}
@@ -161,7 +180,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
@@ -169,7 +188,8 @@ public static org.hamcrest.core.CombinableMatcher.CombinableEitherMatcher<
* @param values
* optional values to insert into the tokenized description
*/
- public static org.hamcrest.Matcher describedAs(java.lang.String description, org.hamcrest.Matcher matcher, java.lang.Object... values) {
+ public static org.hamcrest.Matcher describedAs(java.lang.String description, org.hamcrest.Matcher matcher, java.lang.Object... values)
+ {
return org.hamcrest.core.DescribedAs.describedAs(description, matcher, values);
}
@@ -179,11 +199,12 @@ public static org.hamcrest.Matcher describedAs(java.lang.String descripti
* itemMatcher.
* For example:
*
*/
- public static org.hamcrest.Matcher isA(java.lang.Class> type) {
+ public static org.hamcrest.Matcher isA(java.lang.Class> type)
+ {
return org.hamcrest.core.Is.isA(type);
}
/**
* Creates a matcher that always matches, regardless of the examined object.
*/
- public static org.hamcrest.Matcher anything() {
+ public static org.hamcrest.Matcher anything()
+ {
return org.hamcrest.core.IsAnything.anything();
}
/**
* 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
*/
- public static org.hamcrest.Matcher anything(java.lang.String description) {
+ public static org.hamcrest.Matcher anything(java.lang.String description)
+ {
return org.hamcrest.core.IsAnything.anything(description);
}
@@ -246,11 +272,12 @@ public static org.hamcrest.Matcher anything(java.lang.String d
* will stop as soon as a matching item is found.
* For example:
*
- *
+ *
* @param itemMatcher
* the matcher to apply to items provided by the examined {@link Iterable}
*/
- public static org.hamcrest.Matcher> hasItem(org.hamcrest.Matcher super T> itemMatcher) {
+ public static org.hamcrest.Matcher> hasItem(org.hamcrest.Matcher super T> itemMatcher)
+ {
return IsIterableContaining.hasItem(itemMatcher);
}
@@ -261,11 +288,12 @@ public static org.hamcrest.Matcher> hasItem(or
* will stop as soon as a matching item is found.
* For example:
*
- *
+ *
* @param item
* the item to compare against the items provided by the examined {@link Iterable}
*/
- public static org.hamcrest.Matcher> hasItem(T item) {
+ public static org.hamcrest.Matcher> hasItem(T item)
+ {
return IsIterableContaining.hasItem(item);
}
@@ -276,12 +304,13 @@ public static org.hamcrest.Matcher> hasItem(T
* the examined {@link Iterable} will stop as soon as a matching item is found.
* For example:
*
- *
+ *
* @param itemMatchers
* the matchers to apply to items provided by the examined {@link Iterable}
*/
@SafeVarargs
- public static org.hamcrest.Matcher> hasItems(org.hamcrest.Matcher super T>... itemMatchers) {
+ public static org.hamcrest.Matcher> hasItems(org.hamcrest.Matcher super T>... itemMatchers)
+ {
return IsIterableContaining.hasItems(itemMatchers);
}
@@ -292,12 +321,13 @@ public static org.hamcrest.Matcher> hasItems(org.hamcr
* examined {@link Iterable} will stop as soon as a matching item is found.
* For example:
*
- *
+ *
* @param items
* the items to compare against the items provided by the examined {@link Iterable}
*/
@SafeVarargs
- public static org.hamcrest.Matcher> hasItems(T... items) {
+ public static org.hamcrest.Matcher> hasItems(T... items)
+ {
return IsIterableContaining.hasItems(items);
}
@@ -305,24 +335,25 @@ public static org.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's equals method returns true when passed a
* null (which would be a violation of the equals contract), unless the
* examined object itself is null, in which case the matcher will return a positive
* match.
- *
+ *
*
The created matcher provides a special behaviour when examining Arrays, 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.
*/
- public static org.hamcrest.Matcher equalTo(T operand) {
+ public static org.hamcrest.Matcher equalTo(T operand)
+ {
return org.hamcrest.core.IsEqual.equalTo(operand);
}
@@ -330,7 +361,8 @@ public static org.hamcrest.Matcher equalTo(T operand) {
* Creates an {@link org.hamcrest.core.IsEqual} matcher that does not enforce the values being
* compared to be of the same static type.
*/
- public static org.hamcrest.Matcher equalToObject(java.lang.Object operand) {
+ public static org.hamcrest.Matcher equalToObject(java.lang.Object operand)
+ {
return org.hamcrest.core.IsEqual.equalToObject(operand);
}
@@ -338,14 +370,15 @@ public static org.hamcrest.Matcher equalToObject(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
* with(any(Thing.class))
* For example:
*
assertThat(new Canoe(), instanceOf(Canoe.class));
*/
- public static org.hamcrest.Matcher any(java.lang.Class type) {
+ public static org.hamcrest.Matcher any(java.lang.Class type)
+ {
return org.hamcrest.core.IsInstanceOf.any(type);
}
@@ -353,12 +386,13 @@ public static 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.
*/
- public static org.hamcrest.Matcher instanceOf(java.lang.Class> type) {
+ public static org.hamcrest.Matcher instanceOf(java.lang.Class> type)
+ {
return org.hamcrest.core.IsInstanceOf.instanceOf(type);
}
@@ -367,11 +401,12 @@ public static org.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
*/
- public static org.hamcrest.Matcher not(org.hamcrest.Matcher matcher) {
+ public static org.hamcrest.Matcher not(org.hamcrest.Matcher matcher)
+ {
return org.hamcrest.core.IsNot.not(matcher);
}
@@ -381,11 +416,12 @@ public static org.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
*/
- public static org.hamcrest.Matcher not(T value) {
+ public static org.hamcrest.Matcher not(T value)
+ {
return org.hamcrest.core.IsNot.not(value);
}
@@ -396,7 +432,8 @@ public static org.hamcrest.Matcher not(T value) {
* instead of:
*
assertThat(cheese, is(not(nullValue())))
*/
- public static org.hamcrest.Matcher notNullValue() {
+ public static org.hamcrest.Matcher notNullValue()
+ {
return org.hamcrest.core.IsNull.notNullValue();
}
@@ -407,11 +444,12 @@ public static org.hamcrest.Matcher notNullValue() {
*
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
*/
- public static org.hamcrest.Matcher notNullValue(java.lang.Class type) {
+ public static org.hamcrest.Matcher notNullValue(java.lang.Class type)
+ {
return org.hamcrest.core.IsNull.notNullValue(type);
}
@@ -420,7 +458,8 @@ public static org.hamcrest.Matcher notNullValue(java.lang.Class type)
* For example:
*
assertThat(cheese, is(nullValue())
*/
- public static org.hamcrest.Matcher nullValue() {
+ public static org.hamcrest.Matcher nullValue()
+ {
return org.hamcrest.core.IsNull.nullValue();
}
@@ -429,46 +468,50 @@ public static org.hamcrest.Matcher nullValue() {
* 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
*/
- public static org.hamcrest.Matcher nullValue(java.lang.Class type) {
+ public static org.hamcrest.Matcher nullValue(java.lang.Class type)
+ {
return org.hamcrest.core.IsNull.nullValue(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
*/
- public static org.hamcrest.Matcher sameInstance(T target) {
+ public static org.hamcrest.Matcher sameInstance(T target)
+ {
return org.hamcrest.core.IsSame.sameInstance(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) {
+ 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:
*
- *
+ *
* @param substring
* the substring that the returned matcher will expect to find within any examined string
*/
- public static Matcher containsString(java.lang.String substring) {
+ public static Matcher containsString(java.lang.String substring)
+ {
return org.hamcrest.core.StringContains.containsString(substring);
}
@@ -477,11 +520,12 @@ public static Matcher containsString(java.lang.String substrin
* {@link String} anywhere, ignoring case.
* For example:
*
- *
+ *
* @param substring
* the substring that the returned matcher will expect to find within any examined string
*/
- public static Matcher containsStringIgnoringCase(java.lang.String substring) {
+ public static Matcher containsStringIgnoringCase(java.lang.String substring)
+ {
return org.hamcrest.core.StringContains.containsStringIgnoringCase(substring);
}
@@ -492,11 +536,12 @@ public static Matcher containsStringIgnoringCase(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
+ * the substring that the returned matcher will expect at the start of any examined string
*/
- public static Matcher startsWith(java.lang.String prefix) {
+ public static Matcher startsWith(java.lang.String prefix)
+ {
return org.hamcrest.core.StringStartsWith.startsWith(prefix);
}
@@ -507,11 +552,12 @@ public static Matcher startsWith(java.lang.String prefix) {
*
* For example:
*
- *
+ *
* @param prefix
- * the substring that the returned matcher will expect at the start of any examined string
+ * the substring that the returned matcher will expect at the start of any examined string
*/
- public static Matcher startsWithIgnoringCase(java.lang.String prefix) {
+ public static Matcher startsWithIgnoringCase(java.lang.String prefix)
+ {
return org.hamcrest.core.StringStartsWith.startsWithIgnoringCase(prefix);
}
@@ -520,11 +566,12 @@ public static Matcher startsWithIgnoringCase(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
+ * the substring that the returned matcher will expect at the end of any examined string
*/
- public static Matcher endsWith(java.lang.String suffix) {
+ public static Matcher endsWith(java.lang.String suffix)
+ {
return org.hamcrest.core.StringEndsWith.endsWith(suffix);
}
@@ -533,11 +580,12 @@ public static Matcher endsWith(java.lang.String suffix) {
* {@link String}, ignoring case.
* For example:
*
- *
+ *
* @param suffix
- * the substring that the returned matcher will expect at the end of any examined string
+ * the substring that the returned matcher will expect at the end of any examined string
*/
- public static Matcher endsWithIgnoringCase(java.lang.String suffix) {
+ public static Matcher endsWithIgnoringCase(java.lang.String suffix)
+ {
return org.hamcrest.core.StringEndsWith.endsWithIgnoringCase(suffix);
}
@@ -549,10 +597,11 @@ public static Matcher endsWithIgnoringCase(java.lang.String su
*
*
* @param pattern
- * the pattern to be used.
+ * the pattern to be used.
* @return The matcher.
*/
- public static Matcher matchesRegex(Pattern pattern) {
+ public static Matcher matchesRegex(Pattern pattern)
+ {
return StringRegularExpression.matchesRegex(pattern);
}
@@ -564,10 +613,11 @@ public static Matcher matchesRegex(Pattern pattern) {
*
*
* @param regex
- * The regex to be used for the validation.
+ * The regex to be used for the validation.
* @return The matcher.
*/
- public static Matcher matchesRegex(String regex) {
+ public static Matcher matchesRegex(String regex)
+ {
return StringRegularExpression.matchesRegex(Pattern.compile(regex));
}
@@ -577,12 +627,13 @@ public static Matcher matchesRegex(String regex) {
* each matcher[i] is satisfied by array[i].
* For example:
*
- *
+ *
* @param elementMatchers
* the matchers that the elements of examined arrays should satisfy
*/
@SafeVarargs
- public static org.hamcrest.collection.IsArray array(org.hamcrest.Matcher super T>... elementMatchers) {
+ public static org.hamcrest.collection.IsArray array(org.hamcrest.Matcher super T>... elementMatchers)
+ {
return org.hamcrest.collection.IsArray.array(elementMatchers);
}
@@ -592,11 +643,12 @@ public static org.hamcrest.collection.IsArray array(org.hamcrest.Matcher<
* of the examined array will stop as soon as a matching element is found.
* For example:
*
- *
+ *
* @param elementMatcher
* the matcher to apply to elements in examined arrays
*/
- public static org.hamcrest.Matcher hasItemInArray(org.hamcrest.Matcher super T> elementMatcher) {
+ public static org.hamcrest.Matcher hasItemInArray(org.hamcrest.Matcher super T> elementMatcher)
+ {
return ArrayMatching.hasItemInArray(elementMatcher);
}
@@ -606,11 +658,12 @@ public static org.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
*/
- public static org.hamcrest.Matcher hasItemInArray(T element) {
+ public static org.hamcrest.Matcher hasItemInArray(T element)
+ {
return ArrayMatching.hasItemInArray(element);
}
@@ -620,12 +673,13 @@ public static org.hamcrest.Matcher hasItemInArray(T element) {
* the examined array must be of the same length as the number of specified items.
* For example:
*
- *
+ *
* @param items
* the items that must equal the items within an examined array
*/
@SafeVarargs
- public static org.hamcrest.Matcher arrayContaining(E... items) {
+ public static org.hamcrest.Matcher arrayContaining(E... items)
+ {
return ArrayMatching.arrayContaining(items);
}
@@ -635,12 +689,13 @@ public static org.hamcrest.Matcher arrayContaining(E... items) {
* must be of the same length as the number of specified matchers.
* For example:
*
- *
+ *
* @param itemMatchers
* the matchers that must be satisfied by the items in the examined array
*/
@SafeVarargs
- public static org.hamcrest.Matcher arrayContaining(org.hamcrest.Matcher super E>... itemMatchers) {
+ public static org.hamcrest.Matcher arrayContaining(org.hamcrest.Matcher super E>... itemMatchers)
+ {
return ArrayMatching.arrayContaining(itemMatchers);
}
@@ -650,11 +705,12 @@ public static org.hamcrest.Matcher arrayContaining(org.hamcrest.Matcher
* must be of the same length as the specified list of matchers.
* For example:
*
- *
+ *
* @param itemMatchers
* a list of matchers, each of which must be satisfied by the corresponding item in an examined array
*/
- public static org.hamcrest.Matcher arrayContaining(java.util.List> itemMatchers) {
+ public static org.hamcrest.Matcher arrayContaining(java.util.List> itemMatchers)
+ {
return ArrayMatching.arrayContaining(itemMatchers);
}
@@ -674,12 +730,13 @@ public static org.hamcrest.Matcher arrayContaining(java.util.List
*
- *
+ *
* @param itemMatchers
* a list of matchers, each of which must be satisfied by an entry in an examined array
*/
@SafeVarargs
- public static org.hamcrest.Matcher arrayContainingInAnyOrder(org.hamcrest.Matcher super E>... itemMatchers) {
+ public static org.hamcrest.Matcher arrayContainingInAnyOrder(org.hamcrest.Matcher super E>... itemMatchers)
+ {
return ArrayMatching.arrayContainingInAnyOrder(itemMatchers);
}
@@ -699,11 +756,12 @@ public static org.hamcrest.Matcher arrayContainingInAnyOrder(org.hamcre
* For example:
*
*
- *
+ *
* @param itemMatchers
* a list of matchers, each of which must be satisfied by an item provided by an examined array
*/
- public static org.hamcrest.Matcher arrayContainingInAnyOrder(java.util.Collection> itemMatchers) {
+ public static org.hamcrest.Matcher arrayContainingInAnyOrder(java.util.Collection> itemMatchers)
+ {
return ArrayMatching.arrayContainingInAnyOrder(itemMatchers);
}
@@ -721,12 +779,13 @@ public static org.hamcrest.Matcher arrayContainingInAnyOrder(java.util.
* For example:
*
*
- *
+ *
* @param items
* the items that must equal the entries of an examined array, in any order
*/
@SafeVarargs
- public static org.hamcrest.Matcher arrayContainingInAnyOrder(E... items) {
+ public static org.hamcrest.Matcher arrayContainingInAnyOrder(E... items)
+ {
return ArrayMatching.arrayContainingInAnyOrder(items);
}
@@ -735,11 +794,12 @@ public static org.hamcrest.Matcher arrayContainingInAnyOrder(E... items
* satisfies the specified matcher.
* For example:
*
- *
+ *
* @param sizeMatcher
* a matcher for the length of an examined array
*/
- public static org.hamcrest.Matcher arrayWithSize(org.hamcrest.Matcher super java.lang.Integer> sizeMatcher) {
+ public static org.hamcrest.Matcher arrayWithSize(org.hamcrest.Matcher super java.lang.Integer> sizeMatcher)
+ {
return org.hamcrest.collection.IsArrayWithSize.arrayWithSize(sizeMatcher);
}
@@ -748,11 +808,12 @@ public static org.hamcrest.Matcher arrayWithSize(org.hamcrest.Matcher
* equals the specified size.
* For example:
*
- *
+ *
* @param size
* the length that an examined array must have for a positive match
*/
- public static org.hamcrest.Matcher arrayWithSize(int size) {
+ public static org.hamcrest.Matcher arrayWithSize(int size)
+ {
return org.hamcrest.collection.IsArrayWithSize.arrayWithSize(size);
}
@@ -762,7 +823,8 @@ public static org.hamcrest.Matcher arrayWithSize(int size) {
* For example:
*
assertThat(new String[0], emptyArray())
*/
- public static org.hamcrest.Matcher emptyArray() {
+ public static org.hamcrest.Matcher emptyArray()
+ {
return org.hamcrest.collection.IsArrayWithSize.emptyArray();
}
@@ -771,11 +833,12 @@ public static org.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 static org.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 +847,12 @@ 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 static org.hamcrest.Matcher> aMapWithSize(int size) {
+ public static org.hamcrest.Matcher> aMapWithSize(int size)
+ {
return org.hamcrest.collection.IsMapWithSize.aMapWithSize(size);
}
@@ -798,7 +862,8 @@ public static org.hamcrest.Matcher
* For example:
*
assertThat(myMap, is(anEmptyMap()))
*/
- public static org.hamcrest.Matcher> anEmptyMap() {
+ public static org.hamcrest.Matcher> anEmptyMap()
+ {
return org.hamcrest.collection.IsMapWithSize.anEmptyMap();
}
@@ -807,11 +872,12 @@ public static org.hamcrest.Matcher
* a value that satisfies the specified matcher.
* For example:
*
- *
+ *
* @param sizeMatcher
* a matcher for the size of an examined {@link java.util.Collection}
*/
- public static org.hamcrest.Matcher> hasSize(org.hamcrest.Matcher super java.lang.Integer> sizeMatcher) {
+ public static org.hamcrest.Matcher> hasSize(org.hamcrest.Matcher super java.lang.Integer> sizeMatcher)
+ {
return org.hamcrest.collection.IsCollectionWithSize.hasSize(sizeMatcher);
}
@@ -820,11 +886,12 @@ public static org.hamcrest.Matcher> hasSiz
* a value equal to the specified size.
* For example:
*