We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A lot of beans are also Serializable.
Please consider a matcher for checking whether an explicit serialVersionUID has been set.
@Factory public static Matcher<Class<?>> hasSerialVersionUIDField() { return new HasSerialVersionUIDFieldMatcher(); }
public final class HasSerialVersionUIDFieldMatcher extends TypeSafeDiagnosingMatcher<Class<?>> { @Override protected boolean matchesSafely(Class<?> item, Description mismatchDescription) { boolean hasExplicitSerialVersionUIDField = hasExplicitSerialVersionUIDField(item); if (!hasExplicitSerialVersionUIDField) { mismatchDescription .appendText("bean of type ") .appendValue(item.getName()) .appendText(" does not have a serialVersionUID field"); } return hasExplicitSerialVersionUIDField; } @Override public void describeTo(Description description) { description.appendText("bean class has a serialVersionUID field"); } private boolean hasExplicitSerialVersionUIDField(Class<?> item) { try { item.getDeclaredField("serialVersionUID"); } catch (NoSuchFieldException ignored) { return false; } return true; } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
A lot of beans are also Serializable.
Please consider a matcher for checking whether an explicit serialVersionUID has been set.
The text was updated successfully, but these errors were encountered: