aboutsummaryrefslogtreecommitdiff
path: root/library/src/org
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2016-12-14 13:16:00 +0000
committerPaul Duffin <paulduffin@google.com>2016-12-14 13:16:00 +0000
commit3d6708ec441be10a8d4807dbf170de3656213dbb (patch)
tree4fa3e8d4ca4eb22bf191b4075d33694e6d305d99 /library/src/org
parent9a60bf31008014670e3ad9b4def49688a91672ff (diff)
downloadhamcrest-3d6708ec441be10a8d4807dbf170de3656213dbb.tar.gz
Remove hamcrest-integration
This target is not used and the module does not exist in Hamcrest 2.0. In Hamcrest 2.0 the file it contains has been merged into the hamcrest-core module, which is represented in Android by the hamcrest/hamcrest-host/hamcrest-hostdex build targets. Similarly, in Hamcrest 2.0 the TypeSafeMatcher class is in the hamcrest-core module and not the hamcrest-library module. This moves the two classes into the appropriate module in preparation for upgrading JUnit to 4.12 and Hamcrest to 2.0. Bug: 33613916 Bug: 30946317 Test: make checkbuild Change-Id: Ib22cf3dce1180b3df12764093b727ff2482c51e5
Diffstat (limited to 'library/src/org')
-rw-r--r--library/src/org/hamcrest/TypeSafeMatcher.java58
1 files changed, 0 insertions, 58 deletions
diff --git a/library/src/org/hamcrest/TypeSafeMatcher.java b/library/src/org/hamcrest/TypeSafeMatcher.java
deleted file mode 100644
index 7f18fd3..0000000
--- a/library/src/org/hamcrest/TypeSafeMatcher.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.hamcrest;
-
-import java.lang.reflect.Method;
-
-/**
- * Convenient base class for Matchers that require a non-null value of a specific type.
- * This simply implements the null check, checks the type and then casts.
- *
- * @author Joe Walnes
- */
-public abstract class TypeSafeMatcher<T> extends BaseMatcher<T> {
-
- private Class expectedType;
-
- /**
- * Subclasses should implement this. The item will already have been checked for
- * the specific type and will never be null.
- */
- public abstract boolean matchesSafely(T item);
-
- protected TypeSafeMatcher() {
- expectedType = findExpectedType(getClass());
- }
-
- private static Class<?> findExpectedType(Class<?> fromClass) {
- for (Class<?> c = fromClass; c != Object.class; c = c.getSuperclass()) {
- for (Method method : c.getDeclaredMethods()) {
- if (isMatchesSafelyMethod(method)) {
- return method.getParameterTypes()[0];
- }
- }
- }
-
- throw new Error("Cannot determine correct type for matchesSafely() method.");
- }
-
- private static boolean isMatchesSafelyMethod(Method method) {
- return method.getName().equals("matchesSafely")
- && method.getParameterTypes().length == 1
- && !method.isSynthetic();
- }
-
- protected TypeSafeMatcher(Class<T> expectedType) {
- this.expectedType = expectedType;
- }
-
- /**
- * Method made final to prevent accidental override.
- * If you need to override this, there's no point on extending TypeSafeMatcher.
- * Instead, extend the {@link BaseMatcher}.
- */
- @SuppressWarnings({"unchecked"})
- public final boolean matches(Object item) {
- return item != null
- && expectedType.isInstance(item)
- && matchesSafely((T) item);
- }
-}