I have a Java method with the following signature:
public <T> List<HtmlOptionsComposite> convertToHtmlOptionsCompositeList
(List<? extends T> objects,
Class<T> clazz,
String getValueMethodName,
String getDescriptionMethodName,
String getDiscontinuedMethodName)
{ ... }
The clazz
parameter is required by the method to use reflection (clazz.getMethod(...)
) on each of the given objects, but do I really need to pass it in as a parameter to the method? Is there any way I can refactor the code to work out what clazz should be automatically?