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.SerializableThis 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 ofMatcherare not. This class works around that limitation asAssumptionViolatedExceptiononly 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.StringmatcherDescription
-
Constructor Summary
Constructors Modifier Constructor Description privateSerializableMatcherDescription(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.voiddescribeTo(org.hamcrest.Description description)booleanmatches(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:
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.
-
-