How can I get type safety for a set of classes when there are cyclic relationships. I have 3 classes, Router, Interactor and Component such that
abstract class Router<C extends Component, I extends Interactor>
abstract class Interactor<R extends Router>
abstract class Component<I extends Interactor>
I want to ensure that a specific router is tied to a specific component and specific interactor.
Edit The architecture of the app ensures that we have exactly 1 router for 1 interactor for 1 component. Some reuse is possible but if router A is with interactor A and component A it will always be that way, otherwise we would define router B with interactor A and component B for example.
Edit 2 A more concrete example: We can have the login screen which has loginscreenrouter, loginscreeninteractor and loginscreencomponent and then the loading screen which has 3 more classes in the same structure. But what we don't want is for developers to accidentally pass the loadingscreeninteractor to the loginscreenrouter