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
ConstructorsModifierConstructorDescriptionprivateSerializableMatcherDescription(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.voiddescribeTo(org.hamcrest.Description description) booleanMethods 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:
matchesin interfaceorg.hamcrest.Matcher<T>
-
describeTo
public void describeTo(org.hamcrest.Description description) - Specified by:
describeToin 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.
-