* Override this for GQuery methods which loop over matched elements and
* invoke a callback on each element.
*/
- public Object f(Element e, int i) {
+ public <W> W f(Element e, int i) {
Widget w = GQuery.getAssociatedWidget(e);
if (w != null){
- return f(w, i);
+ f(w, i);
} else {
f((com.google.gwt.user.client.Element)e);
- return "";
}
+ return null;
}
/**
* Override this for GQuery methods which loop over matched widgets and
* invoke a callback on each widget.
*/
- public Object f(Widget w, int i) {
+ public <W> W f(Widget w, int i) {
f(w.getElement());
- return "";
+ return null;
}
/**
import java.util.ArrayList;\r
import java.util.Arrays;\r
import java.util.List;\r
+import java.util.Map;\r
\r
import com.google.gwt.core.client.GWT;\r
import com.google.gwt.core.client.JavaScriptObject;\r
* Pass each element in the current matched set through a function, producing\r
* a new array containing the return values.\r
*/\r
- @SuppressWarnings("unchecked")\r
public <W> List<W> map(Function f) {\r
- @SuppressWarnings("rawtypes")\r
- ArrayList ret = new ArrayList();\r
+ ArrayList<W> ret = new ArrayList<W>();\r
for (int i = 0; i < elements().length; i++) {\r
- Object o = f.f(elements()[i], i);\r
+ @SuppressWarnings("unchecked")\r
+ W o = (W)f.f(elements()[i], i);\r
if (o != null) {\r
ret.add(o);\r
}\r