From a80cfbe63a4997b40ca3125577ccce20eb2eab64 Mon Sep 17 00:00:00 2001 From: Julien Dramaix Date: Mon, 9 Jan 2012 15:34:32 +0000 Subject: [PATCH] add enum support --- .../gwt/query/rebind/JsonBuilderGenerator.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 3fcb79bf..ea358f90 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 @@ -44,8 +44,10 @@ public class JsonBuilderGenerator extends Generator { static JClassType jsonBuilderType; static JClassType stringType; static JClassType jsType; - static JClassType listType; + static JClassType listType; static JClassType functionType; + static JClassType enumType; + public String generate(TreeLogger treeLogger, GeneratorContext generatorContext, String requestedClass) @@ -55,8 +57,9 @@ public class JsonBuilderGenerator extends Generator { jsonBuilderType = oracle.findType(JsonBuilder.class.getName()); stringType = oracle.findType(String.class.getName()); jsType = oracle.findType(JavaScriptObject.class.getName()); - listType = oracle.findType(List.class.getName()); + listType = oracle.findType(List.class.getName()); functionType = oracle.findType(Function.class.getName()); + enumType = oracle.findType(Enum.class.getName()); String t[] = generateClassName(clazz); @@ -153,9 +156,10 @@ public class JsonBuilderGenerator extends Generator { sw.println("return " + ret + ";"); } else { sw.println("return Arrays.asList(" + ret + ");"); - } - - } else { + } + } else if (isTypeAssignableTo(method.getReturnType(), enumType)){ + sw.println("return "+method.getReturnType().getQualifiedSourceName()+".valueOf(p.getStr(\"" + name + "\"));"); + }else { sw.println("System.err.println(\"JsonBuilderGenerator WARN: unknown return type " + retType + " " + ifaceName + "." + methName + "()\"); "); // We return the object because probably the user knows how to handle it -- 2.39.5