Top Description Fields Constructors Methods
org.hamcrest

public abstract Class CustomTypeSafeMatcher<T>

extends TypeSafeMatcher<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 CustomTypeSafeMatcher<String>("a non empty string") {
  public boolean matchesSafely(String string) {
    return !string.isEmpty();
  }
  public void describeMismatchSafely(String string, Description mismatchDescription) {
    mismatchDescription.appendText("was empty");
  }
};
This is a variant of CustomMatcher that first type checks the argument being matched. By the time TypeSafeMatcher#matchesSafely is is called the argument is guaranteed to be non-null and of the correct type.
Author
Neil Dunn

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public

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.TypeSafeMatcher:
describeMismatchdescribeMismatchSafelymatchesmatchesSafely

Field Detail

fixedDescriptionback to summary
private final String fixedDescription

Constructor Detail

CustomTypeSafeMatcherback to summary
public CustomTypeSafeMatcher(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