I'm writing a program in which I'm using the factory pattern. I have an interface called AssetFundCalculator and a class named AssetFundCalculatorImpl which implements the interface.
The AssetFundValidator class validates some inputs, and is able to instantiate a valid AssetFundCalculatorImpl.
I'd like if the rest of the program would only know about the interface, and not about the AssetFundCalculatorImpl, so that only the AssetFundValidator could instantiate it.
My package structure is looking like this:
In Java, I would give package visibility modifier to the AssetFundCalculatorImpl class, or it's constructor, and it would solve the issue, but in Kotlin, there is no package visibility modifier.
Is there a solution to this? I don't want to put this code to a separately compiled module, so the internal modifier is not going to work.