diff options
author | Maxime Meriouma-Caron <meriou@gmail.com> | 2015-12-11 10:36:26 -0500 |
---|---|---|
committer | Maxime Meriouma-Caron <meriou@gmail.com> | 2015-12-11 10:36:26 -0500 |
commit | 6dc8dac88823dd97c47fb1dad42a52d236c583df (patch) | |
tree | 6d8d757188fc6a43b4dc90a4f962a557ce1dc1c8 | |
parent | 6a136c1577ba05c053d4711ab30438f169c7acd3 (diff) | |
parent | 26507a9c986908c3671ced8f14f30a60c84549c1 (diff) | |
download | gwtquery-6dc8dac88823dd97c47fb1dad42a52d236c583df.tar.gz gwtquery-6dc8dac88823dd97c47fb1dad42a52d236c583df.zip |
Merge pull request #368 from ArcBees/mmc_fix_lazy
Fix lazy() ClassCastException and DataBinding tests
5 files changed, 13 insertions, 7 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java index 996f245c..113d6fd6 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java @@ -26,6 +26,7 @@ import com.google.gwt.query.client.js.JsObjectArray; import com.google.gwt.query.client.js.JsUtils; import java.util.Arrays; +import java.util.Collection; import java.util.List; /** @@ -166,6 +167,11 @@ public abstract class JsonBuilderBase<J extends JsonBuilderBase<?>> implements J public <T extends IsProperties> T set(Object key, Object val) { if (val instanceof IsProperties) { p.set(key, ((IsProperties) val).getDataImpl()); + } else if (val instanceof Object[]) { + setArrayBase(String.valueOf(key), (Object[]) val); + } else if (val instanceof Collection) { + Collection collection = (Collection) val; + setArrayBase(String.valueOf(key), collection.toArray(new Object[collection.size()])); } else { p.set(key, val); } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java index e30b7588..86bf6377 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java @@ -209,7 +209,7 @@ public class JsonBuilderGenerator extends Generator { if (arr != null) { sw.println("return " + ret + ";"); } else { - sw.println("return Arrays.asList(" + ret + ");"); + sw.println("return (a == null ? null : Arrays.asList(" + ret + "));"); } } else if (method.getReturnType().isEnum() != null) { sw.println("return " + method.getReturnType().getQualifiedSourceName() diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/LazyGenerator.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/LazyGenerator.java index 0a2cce56..68d4895e 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/LazyGenerator.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/LazyGenerator.java @@ -207,7 +207,7 @@ public class LazyGenerator extends Generator { } sw.println( - "ctx = GQuery.$(getElement()).as(" + nonLazyType.getQualifiedSourceName() + "." + "ctx = GQuery.$((Element) getElement()).as(" + nonLazyType.getQualifiedSourceName() + "." + classID + ");"); sw.println("for (int i = 0; i < closures.length(); i++) {"); sw.indent(); diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java index 395a38a3..0cece814 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java @@ -349,4 +349,4 @@ public class JsonBuilderHandler implements InvocationHandler { return ispropertyGetters; } -}
\ No newline at end of file +} diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java index 1767da99..903ef138 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java @@ -230,11 +230,11 @@ public class DataBindingTestJre extends GWTTestCase { user.set("name", "Random Name"); user.set("phones", Collections.emptyList()); String json = user.toJson(); - + //WHEN fetching that user GUser retrievedUser = GQ.create(GUser.class); retrievedUser.parse(json, true); - + //THEN assertEquals(0, retrievedUser.getPhones().size()); } @@ -249,9 +249,9 @@ public class DataBindingTestJre extends GWTTestCase { //WHEN fetching that user GUser retrievedUser = GQ.create(GUser.class); retrievedUser.parse(json, true); - + //THEN List<String> phones = retrievedUser.getPhones(); assertNull(phones); } -}
\ No newline at end of file +} |