pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alejandro Vilar" <alejandro.vi...@synacom.com.bo>
Subject Question about generics in some classes
Date Wed, 23 Jun 2010 00:11:50 GMT
Hi,

Currently I'm working a lot with TableViews and WebQueries in my project and
my question is mainly about those classes.

Is there a particular reason why TableView doesn't support generics? Cast
all the time TableView#getSelectedRow() it's a little bit ugly, the same
with web queries, maybe using two types could be handy one for the task
type(Void/Url) and one for the result/value/serializer. Or simply at the
method level like:

 

TableView:

 

public <T> T getSelectedRow() {

        int index = getSelectedIndex();

        Object row = null;

        if (index >= 0) {

            row = tableData.get(index);

        }

        return (T)row;

}

Or:

public <T> T getSelectedRow(Class<T> requiredClass) {

        int index = getSelectedIndex();

        Object row = null;

        if (index >= 0) {

            row = tableData.get(index);

        }

        return requiredClass.cast(row);

}

 

GetQuery:

 

public <T> T execute() {.}

 

Also with query parameters, this is not a big deal, but including shortcut
methods as follows can be helpful:

putParameter(String key, int value);

putParameter(String key, double value);

putParameter(String key, boolean value);

putParameter(String key, Object value);

 

Thanks,

Alejandro

 

 

 

 

 


Mime
View raw message