I’m new to annotations. What I am trying to do is write one that includes others. I’ve never needed one before and I’m new to them so this is partially for the learning experience.
I have a checkstyle exemption for some third party code and nobody wants to add the exemption to the Sonar server for me. What I want to do is write a super-annotation that will allow me to be selective with my checkstyle exclusions rather than applying @SupressWarnings(“all”) which seems dangerous to me. The proposed annotation basically just applies groups of @SupressWarnings(“put checkstyle keys here”). First version will just exclude all checkstyle. Next version will add capability to do so by category, subcategory and so on down to closer to leaf exclusions. Could use any advice I can get. Am in the process of reading what ever I can get on annotations right now but also have not used reflection much either.
The SuppressWarnings annotations is very compiler/IDE specific. You cannot make your own annotation entries within it that will magically modify the Java compiler – unless you are willing to do a project-lombok style code generation to change the @SuppressWarnings(“your-specific-syntax”) to various other @SuppressWarnings. For that you have to interact with the AST. Look at the Lombok source code and read up on Annotation Processing Tool (APT).