How to declare a method with a parameter, which should be at the same time a specific class that implements a specific interface without declaring a special class for it?
Suppose I declare an ImageX class and also declare a Tagging interface. Therefore, I need to create another class or method that should only receive ImageX instances that implement the Tagging interface. How to declare such a method? sort of
private void someMethod (ImageX<Tagging> obj){}
but this, of course, is wrong. Yes, I could check obj if it implements the necessary interface, but I want to check the parameters. And what if this is not some method, but a constructor ...
can I ask about generics?
source
share