I am using dependency injection to inject an implementation of an interface. I would like to make it possible to call a method on the injected type with a parameter whose implementation is also being injected and based on an Interface.
Example:
SessionInterfaceis implemented bySession_AandSession_BConfigInterfaceis implemented byConfig_AandConfig_BSession_Ashould only use objects ofConfig_A, same with_B
In the application an implementation of a session is injected (without a config). Later, an implementation of config can be injected, to use it as a parameter for the session's method run(ConfigInterface config)
In this method I'd like to make sure that the given parameter's type is the one corresponding to the session.
Should I use getClass(), instanceof or something else to check this?