Which pattern can be used, or what is the way, if I have some classes where some of the interface are protected, but I want to use it outside the package and out of the hierarchy?
I don’t want to change the access modifier of those old (legacy) classes.
Which pattern can be used, or what is the way, if I have some
Share
You can use a class Adapter. The Class adapter will derive from the Legacy classes and expose public interface methods which will internally call your protected methods. Your client will call the public methods of the class adapter which will internally call your legacy classes.