Java’s Package Private Visibility is an underrated feature. When you omit any visibility modifier in java, then the default (for most objects) is package private, ie the object is visible only only to types in the same package:
class YouDontSeeMe {}
class YouDontSeeMeEither {}
In fact, a compilation unit (the .java
File) Can Contain Multiple Such Classes. You don’t have to create a file per package private type. You could eat put all of these types in your package-info.java
File, it doesn’t matter.
When Using Jooq’s Code Generator, Things are generated as public
Types per default, as you are likely going to use this generated code everything. You can still restrict access using java 9’s module
System if you want.
But occasionally, even with Jooq Generated Code, Package Private Visibility Can Be Useful, If Some Data Access Package Wants Wants Wants to Hide Its Implementation Details from in the module.
Here’s an example code generation configuration to make this happen:
com.example.codegen.SinglePackageStrategy
NONE
com.example
false
That wasn’t too hard? Using this approach, you can ensure that your jooq generated code never leaks into any client code that should be called
Ramesh Ghorai is the founder of www.livenewsblogger.com, a platform dedicated to delivering exclusive live news from across the globe and the local market. With a passion for covering diverse topics, he ensures readers stay updated with the latest and most reliable information. Over the past two years, Ramesh has also specialized in writing top software reviews, partnering with various software companies to provide in-depth insights and unbiased evaluations. His mission is to combine news reporting with valuable technology reviews, helping readers stay informed and make smarter choices.