Skip to content

Commit

Permalink
Fix names in Data binder generators. Fixes issue #230
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Dec 18, 2013
1 parent 9a9f2b0 commit 0e9a003
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public String generate(TreeLogger treeLogger,
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void generateMethod(SourceWriter sw, JMethod method, TreeLogger logger)
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ interface Item extends JsonBuilder {
interface JsonExample extends JsonBuilder {
int getA();
JsonExample getB();
@Name("M")
int getM();
@Name("u")
String getUrl();
long getD();
Expand All @@ -87,14 +89,14 @@ interface JsonExample extends JsonBuilder {
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());
Expand Down Expand Up @@ -129,12 +131,10 @@ public void f() {
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 {
}
Expand Down

0 comments on commit 0e9a003

Please sign in to comment.