Top Description Constructors Methods
org.hamcrest

public abstract Class DiagnosingMatcher<T>

extends BaseMatcher<T>
Class Inheritance
Known Direct Subclasses
org.hamcrest.core.AllOf, org.hamcrest.core.IsInstanceOf

TODO(ngd): Document.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final void
describeMismatch(Object
The item that the Matcher has rejected.
item
,
Description
The description to be built or appended to.
mismatchDescription
)

Overrides org.hamcrest.BaseMatcher.describeMismatch.

Implements org.hamcrest.Matcher.describeMismatch.

Generate a description of why the matcher has not accepted the item.
public final boolean
matches(Object
the object against which the matcher is evaluated.
item
)

Implements org.hamcrest.Matcher.matches.

Evaluates the matcher for argument item.
protected abstract boolean
matches(Object item, Description mismatchDescription)

Inherited from org.hamcrest.BaseMatcher:
_dont_implement_Matcher___instead_extend_BaseMatcher_toString

Constructor Detail

DiagnosingMatcherback to summary
public DiagnosingMatcher()

Method Detail

describeMismatchback to summary
public final void describeMismatch(Object item, Description mismatchDescription)

Overrides org.hamcrest.BaseMatcher.describeMismatch.

Implements org.hamcrest.Matcher.describeMismatch.

Doc from org.hamcrest.Matcher.describeMismatch.

Generate a description of why the matcher has not accepted the item. The description will be part of a larger description of why a matching failed, so it should be concise. This method assumes that matches(item) is false, but will not check this.

Parameters
item:Object

The item that the Matcher has rejected.

mismatchDescription:Description

The description to be built or appended to.

Annotations
@Override
matchesback to summary
public final boolean matches(Object item)

Implements org.hamcrest.Matcher.matches.

Doc from org.hamcrest.Matcher.matches.

Evaluates the matcher for argument item.

This method matches against Object, instead of the generic type T. This is because the caller of the Matcher does not know at runtime what the type is (because of type erasure with Java generics). It is down to the implementations to check the correct type.

Parameters
item:Object

the object against which the matcher is evaluated.

Returns:boolean

true if item matches, otherwise false.

Annotations
@Override
matchesback to summary
protected abstract boolean matches(Object item, Description mismatchDescription)