The idea is to define a base class that can call methods defined in derrived classes, but at creation time I want to make sure that such methods are defined exactly as required, that is, methods take only one argument, HashMap <String String>.
So far, I could verify with the following code that the method contains only one parameter and that it belongs to the HashMap class, but how can I verify that the general definition is <String, String>?
public boolean isMethodParameterValid(final Method method) {
final Class<?>[] parameters = method.getParameterTypes();
return ((parameters.length == 1) && parameters[0].isAssignableFrom(HashMap.class));
}
Two
source
share