Java’s package deal non-public visibility is an underrated characteristic. Whenever you omit any visibility modifier in Java, then the default (for many objects) is package deal non-public, i.e. the article is seen solely to sorts in the identical package deal:
class YouDontSeeMe {}
class YouDontSeeMeEither {}
The truth is, a compilation unit (the .java
file) can comprise a number of such courses. You don’t must create a file per package deal non-public sort. You might even put all of those sorts in your package-info.java
file, it doesn’t matter.
When utilizing jOOQ’s code generator, issues are generated as public
sorts per default, as you’re possible going to make use of this generated code in every single place. You may nonetheless prohibit entry utilizing Java 9’s module
system if you need.
However sometimes, even with jOOQ generated code, package deal non-public visibility may be helpful, if some knowledge entry package deal desires to cover its implementation particulars from different packages within the module.
Right here’s an instance code era configuration to make this occur:
com.instance.codegen.SinglePackageStrategy
NONE
com.instance
false
That wasn’t too onerous? Utilizing this strategy, you may make sure that your jOOQ generated code by no means leaks into any consumer code that shouldn’t see jOOQ sorts.