Top Description Fields Constructors Methods
org.hamcrest

public abstract Class FeatureMatcher<T, U>

extends TypeSafeDiagnosingMatcher<T>
Class Inheritance
Type Parameters
<T>
The type of the object to be matched
<U>
The type of the feature to be matched
Imports
org.hamcrest.internal.ReflectiveTypeFinder

Supporting class for matching a feature of an object. Implement featureValueOf() in a subclass to pull out the feature to be matched against.

Field Summary

Modifier and TypeField and Description
private final String
private final String
private final Matcher<? super U>
private static final ReflectiveTypeFinder

Constructor Summary

AccessConstructor and Description
public
FeatureMatcher(Matcher<? super U>
The matcher to apply to the feature
subMatcher
,
String
Descriptive text to use in describeTo
featureDescription
,
String
Identifying text for mismatch message
featureName
)

Constructor

Method Summary

Modifier and TypeMethod and Description
public final void
describeTo(Description
The description to be built or appended to.
description
)

Implements org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object.
protected abstract U

Returns:

the feature to be matched
featureValueOf
(T
the target object
actual
)

Implement this to extract the interesting feature.

protected boolean
matchesSafely(T actual, Description mismatch)

Implements abstract org.hamcrest.TypeSafeDiagnosingMatcher.matchesSafely.

Subclasses should implement this.
Inherited from org.hamcrest.TypeSafeDiagnosingMatcher:
describeMismatchmatches

Field Detail

featureDescriptionback to summary
private final String featureDescription
featureNameback to summary
private final String featureName
subMatcherback to summary
private final Matcher<? super U> subMatcher
TYPE_FINDERback to summary
private static final ReflectiveTypeFinder TYPE_FINDER

Hides org.hamcrest.TypeSafeDiagnosingMatcher.TYPE_FINDER.

Constructor Detail

FeatureMatcherback to summary
public FeatureMatcher(Matcher<? super U> subMatcher, String featureDescription, String featureName)

Constructor

Parameters
subMatcher:Matcher<? super U>

The matcher to apply to the feature

featureDescription:String

Descriptive text to use in describeTo

featureName:String

Identifying text for mismatch message

Method Detail

describeToback to summary
public final void describeTo(Description description)

Implements org.hamcrest.SelfDescribing.describeTo.

Doc from org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object. The description may be part of a a description of a larger object of which this is just a component, so it should be worded appropriately.

Parameters
description:Description

The description to be built or appended to.

Annotations
@Override
featureValueOfback to summary
protected abstract U featureValueOf(T actual)

Implement this to extract the interesting feature.

Parameters
actual:T

the target object

Returns:U

the feature to be matched

matchesSafelyback to summary
protected boolean matchesSafely(T actual, Description mismatch)

Implements abstract org.hamcrest.TypeSafeDiagnosingMatcher.matchesSafely.

Doc from org.hamcrest.TypeSafeDiagnosingMatcher.matchesSafely.

Subclasses should implement this. The item will already have been checked for the specific type and will never be null.

Annotations
@Override