Top Description Fields Constructors Methods
org.hamcrest

public abstract Class CustomMatcher<T>

extends BaseMatcher<T>
Class Inheritance
Type Parameters
<T>
The type of object being matched.

Utility class for writing one off matchers. For example:
Matcher<String> aNonEmptyString = new CustomMatcher<String>("a non empty string") {
  public boolean matches(Object object) {
    return ((object instanceof String) && !((String) object).isEmpty();
  }
};

This class is designed for scenarios where an anonymous inner class matcher makes sense. It should not be used by API designers implementing matchers.

Author
Neil Dunn
See Also
{@link CustomTypeSafeMatcher} for a type safe variant of this class that you probably want to use.

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public
CustomMatcher(String description)

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.
Inherited from org.hamcrest.BaseMatcher:
_dont_implement_Matcher___instead_extend_BaseMatcher_describeMismatchtoString

Field Detail

fixedDescriptionback to summary
private final String fixedDescription

Constructor Detail

CustomMatcherback to summary
public CustomMatcher(String description)

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