Package org.junit.internal
Class SerializableMatcherDescription<T>
- java.lang.Object
-
- org.hamcrest.BaseMatcher<T>
-
- org.junit.internal.SerializableMatcherDescription<T>
-
- All Implemented Interfaces:
java.io.Serializable
,org.hamcrest.Matcher<T>
,org.hamcrest.SelfDescribing
class SerializableMatcherDescription<T> extends org.hamcrest.BaseMatcher<T> implements java.io.Serializable
This class exists solely to provide a serializable description of a matcher to be serialized as a field inAssumptionViolatedException
. Being aThrowable
, it is required to beSerializable
, but most implementations ofMatcher
are not. This class works around that limitation asAssumptionViolatedException
only every uses the description of theMatcher
, 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 Modifier and Type Field Description private java.lang.String
matcherDescription
-
Constructor Summary
Constructors Modifier Constructor Description private
SerializableMatcherDescription(org.hamcrest.Matcher<T> matcher)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (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
matches(java.lang.Object o)
-
-
-
Constructor Detail
-
SerializableMatcherDescription
private SerializableMatcherDescription(org.hamcrest.Matcher<T> matcher)
-
-
Method Detail
-
matches
public boolean matches(java.lang.Object o)
- 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.
-
-