From: Manolo Carrasco Date: Wed, 18 Dec 2013 18:38:22 +0000 (+0100) Subject: Fix names in Data binder generators. Fixes issue #230 X-Git-Tag: gwtquery-project-1.4.3~54 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0e9a003c78e85d8c535c72b53c68723ed74eda25;p=gwtquery.git Fix names in Data binder generators. Fixes issue #230 --- 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 717fee32..51543454 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 @@ -95,7 +95,7 @@ public class JsonBuilderGenerator extends Generator { String name = nameAnnotation != null ? nameAnnotation.value() : methName.replaceFirst("^(get|set)", ""); - if (nameAnnotation != null) { + if (nameAnnotation == null) { name = name.substring(0, 1).toLowerCase() + name.substring(1); } attrs.add(name); diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/XmlBuilderGenerator.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/XmlBuilderGenerator.java index e8bc27c0..e643ecc1 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/XmlBuilderGenerator.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/XmlBuilderGenerator.java @@ -85,7 +85,7 @@ public class XmlBuilderGenerator extends Generator { String name = nameAnnotation != null ? nameAnnotation.value() : method.getName().replaceFirst("^(get|set)", ""); - if (nameAnnotation != null) { + if (nameAnnotation == null) { name = name.substring(0, 1).toLowerCase() + name.substring(1); } diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java index 92765ce7..4d27f41a 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java @@ -72,6 +72,8 @@ public class GQueryAjaxTestGwt extends GWTTestCase { interface JsonExample extends JsonBuilder { int getA(); JsonExample getB(); + @Name("M") + int getM(); @Name("u") String getUrl(); long getD(); @@ -87,14 +89,14 @@ public class GQueryAjaxTestGwt extends GWTTestCase { Function getF(); void setF(Function f); } - - + boolean functionRun = false; public void testJsonBuilder() { - String json = "{a:1, b:{a:2,b:{a:3}},u:url, d:'2','t':['hola','adios'], 'z': true}"; + String json = "{M:0, a:1, b:{a:2,b:{a:3}},u:url, d:'2','t':['hola','adios'], 'z': true}"; JsonExample c = GWT.create(JsonExample.class); assertEquals(0, c.getA()); c.parse(json, true); + assertEquals(0, c.getM()); assertEquals(1, c.getA()); assertNotNull(c.getB()); assertEquals(2, c.getB().getA()); @@ -129,12 +131,10 @@ public class GQueryAjaxTestGwt extends GWTTestCase { c.setItems(Arrays.asList(items)); assertEquals(2000l, c.getItems().get(0).getDate().getTime()); assertEquals(3000l, c.getItems().get(1).getDate().getTime()); - String s = "{'a':1,'b':{'a':2,'b':{'a':3}},'u':'url','d':1234,'t':['foo','bar'],'z':false,'y':'y','items':[{'date':2000},{'date':3000}]}"; + String s = "{'M':0,'a':1,'b':{'a':2,'b':{'a':3}},'u':'url','d':1234,'t':['foo','bar'],'z':false,'y':'y','items':[{'date':2000},{'date':3000}] assertEquals(s, c.toString().replaceAll("\"", "'")); - - } - + interface XmlExample extends XmlBuilder { interface T extends XmlBuilder { }