Warn or disable direct field access and force a getter
Answered
Hi, is there some annotation or some Java 8 feature to enforce best practices such as warning a programmer in a team not to use direct field access within class, but to use my getter that has some logic & lazy load in it?
Some warning like field might be null and not initialized with direct access -> use getter would be enough.
Please sign in to leave a comment.
There was a related request submitted at https://youtrack.jetbrains.com/v2/issue/IDEA-128132. The user has created a plug-in with the inspection: https://plugins.jetbrains.com/plugin/7866-hibernate-inspections.
It's specific to Hibernate, but you can try adjusting it to your case since the sources are available.
Okay, that looks good indeed! And it will be easy to adjust, I just forked the github repo :-) here: https://github.com/cyberluke/HibernateInspectionsPlugin