private static <T, U> Matcher<U> cast(Class<T> clazz, Matcher<? super T> downcastMatcher) {
return new TypeSafeDiagnosingMatcher<U>() {
@Override
public void describeTo(Description description) {
downcastMatcher.describeTo(description);
}
@Override
protected boolean matchesSafely(Object item, Description mismatchDescription) {
if (!clazz.isInstance(item)) {
mismatchDescription.appendText("was a " + item.getClass().getSimpleName());
return false;
} if (downcastMatcher.matches(item)) {
return true;
} else {
downcastMatcher.describeMismatch(item, mismatchDescription);
return false;
}
}
};
}
DocumentMatchers.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:java-mammoth
作者:
评论列表
文章目录