I have a generic Parameter interface and its ParameterImpl concrete class. The T will be a Float, Long, Integer or String.
public interface Parameter<T extends Comparable<T>> {}
public class ParameterImpl<T extends Comparable<T>> implements Parameter<T> {}
I have several other ordinary classes which will use above generic Parameter type with warnings, like the one followed:
public class ProcessParameter() {
Map<String, Parameter> params; //use <?> or @SuppressWarnings ???
//use <?> or @SuppressWarnings or <T extends Comparable> ???
public Parameter getParameter(String key, Map<String, Parameter> paramMap)
{
}
//use <?> or @SuppressWarnings or <T extends Comparable> ???
public void addParameter(Parameter param)
{
}
//use <?> or @SuppressWarnings or <T extends Comparable> ???
public Map<String, Parameter> getParameterMap()
{
}
//many more cases with Parameter presents
}
For the
Map<String, Parameter> params;
variable case, should I use<?>
or@SuppressWarnings
? Why you suggested way is better?For the method cases, if I use
<?>
or<T extends Comparable>
(in the method signature), then it will affect all other methods related. The@SuppressWarnings
will cover this issue just here. So, which option I should choose? Why the option you suggested is better than others?In most of cases, the Eclipse suggests the
@SuppressWarnings
way. Is the@SuppressWarnings
a right way or it is a temporary solution with potential bug inside?