Package org.junit.internal
Class SerializableMatcherDescription<T>
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.junit.internal.SerializableMatcherDescription<T>
- All Implemented Interfaces:
Serializable
,org.hamcrest.Matcher<T>
,org.hamcrest.SelfDescribing
This class exists solely to provide a serializable description of a matcher to be serialized as a field in
AssumptionViolatedException
. Being a Throwable
, it is required to be Serializable
, but most
implementations of Matcher
are not. This class works around that limitation as
AssumptionViolatedException
only every uses the description of the Matcher
, while still retaining
backwards compatibility with classes compiled against its class signature before 4.14 and/or deserialization of
previously serialized instances.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
SerializableMatcherDescription
(org.hamcrest.Matcher<T> matcher) -
Method Summary
Modifier and TypeMethodDescription(package private) static <T> org.hamcrest.Matcher<T>
asSerializableMatcher
(org.hamcrest.Matcher<T> matcher) Factory method that checks to see if the matcher is already serializable.void
describeTo
(org.hamcrest.Description description) boolean
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, describeMismatch, isNotNull, toString
-
Field Details
-
matcherDescription
-
-
Constructor Details
-
SerializableMatcherDescription
-
-
Method Details
-
matches
- Specified by:
matches
in interfaceorg.hamcrest.Matcher<T>
-
describeTo
public void describeTo(org.hamcrest.Description description) - Specified by:
describeTo
in interfaceorg.hamcrest.SelfDescribing
-
asSerializableMatcher
static <T> org.hamcrest.Matcher<T> asSerializableMatcher(org.hamcrest.Matcher<T> matcher) Factory method that checks to see if the matcher is already serializable.- Parameters:
matcher
- the matcher to make serializable- Returns:
- The provided matcher if it is null or already serializable, the SerializableMatcherDescription representation of it if it is not.
-