import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
+import com.google.gwt.core.client.JsArrayMixed;
+import com.google.gwt.query.client.GQ;
import com.google.gwt.query.client.IsProperties;
import com.google.gwt.query.client.Properties;
import com.google.gwt.query.client.js.JsCache;
return r;
}
+ protected final <T extends JsonBuilder> T[] getIsPropertiesArrayBase(JsArrayMixed js, T[] r, Class<T> clazz) {
+ JsObjectArray<?> a1 = js.cast();
+ for (int i = 0; i < r.length; i++) {
+ r[i] = getIsPropertiesBase(a1.get(i), clazz);
+ }
+ return r;
+ }
+
+ protected final <T extends JsonBuilder> T getIsPropertiesBase(Object o, Class<T> clazz) {
+ return GQ.create(clazz).load(o);
+ }
+
protected Properties getPropertiesBase(String n) {
if (p.getJavaScriptObject(n) == null) {
p.set(n, Properties.create());
sw.println("return p.getStr(\"" + name + "\");");
} else if (isTypeAssignableTo(method.getReturnType(), jsonBuilderType)) {
String q = method.getReturnType().getQualifiedSourceName();
- sw.println("return " + "((" + q + ")GWT.create(" + q + ".class))"
- + ".load(getPropertiesBase(\"" + name + "\"));");
+ sw.println("return " + "getIsPropertiesBase(getPropertiesBase(\"" + name + "\")," + q + ".class);");
} else if (isTypeAssignableTo(method.getReturnType(), settingsType)) {
String q = method.getReturnType().getQualifiedSourceName();
sw.println("return " + "((" + q + ")getPropertiesBase(\"" + name + "\"));");
sw.println("int l = a == null ? 0 : a.length();");
String ret;
if (buildType) {
- sw.println(t + "[] r = new " + t + "[l];");
- sw.println("JsObjectArray<?> a1 = p.getArray(\"" + name
- + "\").cast();");
- sw.println("int l1 = r.length;");
- sw.println("for (int i = 0 ; i < l1 ; i++) {");
- sw.println(" Object w = a1.get(i);");
- sw.println(" " + t + " instance = GWT.create(" + t + ".class);");
- sw.println(" r[i] = instance.load(w);");
- sw.println("}");
- ret = "r";
+ ret = "getIsPropertiesArrayBase(a, new " + t + "[l], " + t + ".class)";
} else {
ret = "getArrayBase(\"" + name + "\", new " + t + "[l], " + t + ".class)";
}
types.add(t);
}
}
+ sw.println("GQuery.console.error(\"GQ.create: not registered class :\" + clz);");
sw.println("return null;");
sw.outdent();
sw.println("}");
Boolean getZ();
String[] getT();
JsonExample setT(String[] strings);
+ Item[] getIt();
+ JsonExample setIt(Item[] items);
JsonExample setZ(Boolean b);
JsonExample setD(long l);
List<Item> getItems();
Item i2 = GQ.create(Item.class);
i2.setDate(new Date(3000));
Item[] items = new Item[]{i1, i2};
+ c.setIt(items);
+ assertEquals(2000l, c.getIt()[0].getDate().getTime());
+ assertEquals(3000l, c.getIt()[1].getDate().getTime());
c.setItems(Arrays.asList(items));
assertEquals(2000l, c.getItems().get(0).getDate().getTime());
assertEquals(3000l, c.getItems().get(1).getDate().getTime());