hamcrest-all-1.3.jar
登录
|
org.hamcrest:hamcrest-all:1.3
META-INF
org
hamcrest
DiagnosingMatcher.java
core
CustomTypeSafeMatcher.java
BaseMatcher.java
internal
MatcherAssert.java
Matchers.java
JMock1Matchers.java
package.html
JavaLangMatcherAssert.java
integration
CustomMatcher.java
SelfDescribing.java
beans
TypeSafeMatcher.java
EasyMock2Matchers.java
StringDescription.java
generator
text
Matcher.java
number
BaseDescription.java
collection
Description.java
Factory.java
xml
CoreMatchers.java
TypeSafeDiagnosingMatcher.java
FeatureMatcher.java
Condition.java
object
FeatureMatcher.java
清空
类结构
package org.hamcrest; import org.hamcrest.internal.
ReflectiveTypeFinder
; /** * Supporting class for matching a feature of an object. Implement <code>featureValueOf()</code> * in a subclass to pull out the feature to be matched against. * * @param <T> The type of the object to be matched * @param <U> The type of the feature to be matched */ public abstract class
FeatureMatcher
<T, U> extends
TypeSafeDiagnosingMatcher
<T> { 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 */ 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 * @return the feature to be matched */ protected abstract U
featureValueOf
(T
actual
); @
Override
protected boolean
matchesSafely
(T
actual
,
Description
mismatch
) { final U
featureValue
=
featureValueOf
(
actual
); if (!
subMatcher
.
matches
(
featureValue
)) {
mismatch
.
appendText
(
featureName
).
appendText
(" ");
subMatcher
.
describeMismatch
(
featureValue
,
mismatch
); return false; } return true; }; @
Override
public final void
describeTo
(
Description
description
) {
description
.
appendText
(
featureDescription
).
appendText
(" ") .
appendDescriptionOf
(
subMatcher
); } }
查找资源
Jre/Lib
输入类名或文件名
类结构窗口