程序包 org.hamcrest
类 CustomTypeSafeMatcher<T>
- java.lang.Object
- org.hamcrest.BaseMatcher<T>
- org.hamcrest.TypeSafeMatcher<T>
- org.hamcrest.CustomTypeSafeMatcher<T>
- 类型参数:
T
- The type of object being matched
- 所有已实现的接口:
Matcher<T>
,SelfDescribing
public abstract class CustomTypeSafeMatcher<T> extends TypeSafeMatcher<T>
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 ofCustomMatcher
that first type checks the argument being matched. By the timeTypeSafeMatcher.matchesSafely(T)
is is called the argument is guaranteed to be non-null and of the correct type.
构造器概要
构造器 构造器 说明 CustomTypeSafeMatcher(String description)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
describeTo(Description description)
Generates a description of the object.从类继承的方法 org.hamcrest.TypeSafeMatcher
describeMismatch, describeMismatchSafely, matches, matchesSafely
从类继承的方法 org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString
构造器详细资料
CustomTypeSafeMatcher
public CustomTypeSafeMatcher(String description)
方法详细资料
describeTo
public final void describeTo(Description description)
从接口复制的说明:SelfDescribing
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.- 参数:
description
- The description to be built or appended to.