-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
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
Adding support for JSR-305 annotations #645
Conversation
Thanks @shrey-garg. I note that JSR-305 is dormant, which I guess means it is not going anywhere and is unlikely to ever be added to Java. Thanks for putting this behind a configuration option. I've never come across this JSR before but I don't have any objections to adding this. I'll take a detailed look through the code and comment on anything that needs to change. |
Thank you. Will incorporate any suggestions that you might have. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you also need to look at RequiredArrayRule.java ("required": true|false
can appear on a property in draft03 style and draft04+ style has "required"
as an array of property names on an object).
Also, this needs some integration tests. Check out IncludeJsr303AnnotationsIT.java.
@@ -458,6 +460,19 @@ public void setIncludeJsr303Annotations(boolean includeJsr303Annotations) { | |||
} | |||
|
|||
/** | |||
* Sets the 'includeJsr303Annotations' property of this class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here, this should be 305
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected
I have made changes to take RequiredArrayRule into consideration and have also added integration tests which validate if the proper annotations have been added or not. |
@shrey-garg This looks good. The only thing I'm going to do here is remove NotRequiredRule.java, because I don't think that it's right to add these comments to all existing code. It's a lot of noise for all projects. |
@joelittlejohn The NotRequired comment should only be added if the JSR-305 flag is on, it won't be added in any other scenario. |
Ah, so it is. I misread this. Thanks! |
Adding support for JSR-305 compatible annotations, for defect detection using libraries like google's find bugs or while using Intellij Idea IDE etc.
It adds @nonnull annotations for all fields that are marked required and @nullable on all fields that are not.