Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added javadocs.

  • Loading branch information...
commit 2f64a8820bb272a7e587266bf80334d12ccab09a 1 parent a00c4b0
@detinho authored
View
9 src/main/java/org/junit/internal/matchers/BothMatcher.java
@@ -6,6 +6,10 @@
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.anyOf;
+/**
+ * Used to combine hamcrest matchers that must both pass.
+ * @see org.junit.matchers.JUnitMatchers#both(Matcher)
+ */
public class BothMatcher<T> extends BaseMatcher<T> {
private final Matcher<? extends T> fMatcher;
@@ -27,6 +31,11 @@ public void describeTo(Description description) {
return new BothMatcher<T>(allOf(matcher, fMatcher));
}
+ /**
+ * @deprecated doesn't make sense to use an or combination in an operation
+ * where both matchers must pass. Use {@link EitherMatcher#or(Matcher)}
+ * instead.
+ */
@SuppressWarnings("unchecked")
@Deprecated
public BothMatcher<T> or(Matcher<? extends T> matcher) {
View
5 src/main/java/org/junit/internal/matchers/CombinableMatcher.java
@@ -6,6 +6,11 @@
import org.hamcrest.Description;
import org.hamcrest.Matcher;
+/**
+ * @deprecated split into {@link BothMatcher} and {@link EitherMatcher} to
+ * provide a better static checking and prevent invalid operations like both().or()
+ * or either().and().
+ */
@Deprecated
public class CombinableMatcher<T> extends BaseMatcher<T> {
View
9 src/main/java/org/junit/internal/matchers/EitherMatcher.java
@@ -6,6 +6,10 @@
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.allOf;
+/**
+ * Used to combine hamcrest matchers that either may pass.
+ * @see org.junit.matchers.JUnitMatchers#either(Matcher)
+ */
public class EitherMatcher<T> extends BaseMatcher<T> {
private final Matcher<? extends T> fMatcher;
@@ -27,6 +31,11 @@ public void describeTo(Description description) {
return new EitherMatcher<T>(anyOf(matcher, fMatcher));
}
+ /**
+ * @deprecated doesn't make sense to use an and combination in an operation
+ * where either matchers may pass. Use {@link BothMatcher#and(Matcher)}}
+ * instead.
+ */
@SuppressWarnings("unchecked")
@Deprecated
public EitherMatcher<T> and(Matcher<? extends T> matcher) {
View
1  src/test/java/org/junit/tests/assertion/BothTest.java
@@ -68,5 +68,4 @@ public void eitherPasses() {
@Test public void subclassesAreOkInSecondPositionOnly() {
assertThat(3, both(is(Integer.class)).and(is(3)));
}
-
}
Please sign in to comment.
Something went wrong with that request. Please try again.