I am trying to create a function which takes two parameters - a class instance and a interface - then returns true if the provided class instance implements the provided interface. My problem is that I cannot find a way to pass a interface as a parameter in this way.
My attempt currently looks something like this:
interface myInterface
{
}
class myClass implements myInterface
{
}
...
// Function to check if a class implements an interface:
boolean doesImplementInterface(object classToTest, ??? interfaceToTestAgainst)
{
if(i.getClass().isInterface())
{
return o.getClass().isInstance(i);
}
return false;
}
...
// Would call the "doesImplementInterface" method like this:
doesImplementInterface(new myClass(), myInterface);
It might be hard to see here, but when defining the "doesImplementInterface" function, I cannot figure out what type the second parameter must be. I am attempting to pass the interface that the provided class will be tested against, but as far as I can find, there is no variable type that I could use to pass a interface in this way.
Is passing a interface as a parameter in this way possible, or should I begin exploring alternative options?