How do I get a method using reflection based on a parameter value when the parameter type is an interface?
In the following case (based on this example), newVal
Another answer suggested using Apache Commons to get the Method object using MethodUtils.getMatchingAccessibleMethod.
However, it looks like you're not using the Method object for anything other than immediately invoking it on an instance. This being the case, you can instead use Apache Commons Lang's MethodUtils.invokeMethod(Object object, String methodName, Object... args). Rather than just returning the Method object, this instead invokes the method on the given object.
protected void addModelProperty(String propertyName, Object newValue) {
try {
MethodUtils.invokeMethod(model, "add" + propertyName, newValue);
} catch (ReflectiveOperationException e) {
}
}