We are trying to keep our code 'consistent' over time on our projects and follow this pattern
https://blog.twitter.com/engineering/en_us/topics/insights/2019/onepattern.html
For any classes annotated with @Entity or @Data, we consider these data objects and would like to enforce that
- The new keyword cannot be used on any objects NOT annotated with @Data (ie. all business logic is created by guice) - This is the hard one here!
- Only get/set/is member methods are in the data objects(perhaps along with equals) - This could be done by scanning and reflection
- All objects with no @Data are annotated with @Singleton(we program in stateless) OR with @ExceptionNotSingleton for exceptions (our exceptions are very rare as we build stateless systems - Could again be done with scanning and reflection
- NO static methods allowed on business objects even utilities -> scan and reflection
The 4th point is for a specific project webpieces where since we use that platform, we can fix bugs in any code by swapping out the class. swapping static methods doesn't work very well.
What tool can do something like this such that I can feed it a simple processor? A gradle plugin would be nice where I can feed it some small snippets of code, but I am not sure that exists.
I could add a unit test to every project as well I guess and then just need a class scanner to inspect the classes.
I am looking for a plugin perhaps with a link to some examples I could try out.