So, the group I work with has reduced the amount of code we have to type for certain things. In this case, a Spring web page that displays a list using the DisplayTag libraries. The way it's done is with a class using generics extending the Controller
object, and then a subclass of that for each page it should work on.
This controller displays the SystemErrorReport
, and defines the type to be the SystemErrorReportCommand
.
public class SystemErrorReportController extends
GenericSearchAndSelectController<SystemErrorReportCommand> {
The problem is that SystemErrorReportCommand
, being passed as a type, needs to have a manual declaration of itself in its constructor, like so:
public SystemErrorReportCommand()
{
super(SystemErrorReport.class);
}
The command object is later passed to something that needs to know its explicit type. Without specifying it manually somewhere, it comes back as GenericCommand
, another class of ours, because the SystemErrorReportCommand
bit is lost after compile time.
I'm not thrilled with that, because it seems like something we can farther automate to reduce developer error. Is there a more elegant way to do this, or am I stuck with this because of type erasure?