The idea is to define a base class that can invoke methods defined in derrived classes, but at creation time I want to ensure, that such methods are defined exactly according to the requirements, which is that the methods take only one argument, a HashMap<String String
>.
So far I was able with the following code to check that the method contains only one parameter and that it is of Class HashMap, but how can I check that the generic definition is <String, String
> ?
public boolean isMethodParameterValid(final Method method) {
final Class<?>[] parameters = method.getParameterTypes();
return ((parameters.length == 1) && parameters[0].isAssignableFrom(HashMap.class));
}