Package org.hamcrest
Class BaseMatcher<T>
java.lang.Object
org.hamcrest.BaseMatcher<T>
- Type Parameters:
T
- The Matcher type.
- All Implemented Interfaces:
Matcher<T>
,SelfDescribing
- Direct Known Subclasses:
AnyOf
,CustomMatcher
,DescribedAs
,DiagnosingMatcher
,Is
,IsAnything
,IsEqual
,IsIn
,IsNot
,IsNull
,IsSame
,TypeSafeDiagnosingMatcher
,TypeSafeMatcher
BaseClass for all Matcher implementations.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
Deprecated.void
describeMismatch
(Object item, Description description) Generate a description of why the matcher has not accepted the item.protected static boolean
isNotNull
(Object actual, Description mismatch) Useful null-check method.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.hamcrest.SelfDescribing
describeTo
-
Constructor Details
-
BaseMatcher
public BaseMatcher()Default constructor.
-
-
Method Details
-
_dont_implement_Matcher___instead_extend_BaseMatcher_
Deprecated.Description copied from interface:Matcher
This method simply acts a friendly reminder not to implement Matcher directly and instead extend BaseMatcher. It's easy to ignore JavaDoc, but a bit harder to ignore compile errors .- Specified by:
_dont_implement_Matcher___instead_extend_BaseMatcher_
in interfaceMatcher<T>
- See Also:
-
describeMismatch
Description copied from interface:Matcher
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 thatmatches(item)
is false, but will not check this.- Specified by:
describeMismatch
in interfaceMatcher<T>
- Parameters:
item
- The item that the Matcher has rejected.description
- The description to be built or appended to.
-
toString
-
isNotNull
Useful null-check method. Writes a mismatch description if the actual object is null- Parameters:
actual
- the object to checkmismatch
- where to write the mismatch description, if any- Returns:
- false iff the actual object is null
-