diff options
author | Julien Dramaix <julien.dramaix@gmail.com> | 2012-01-09 15:34:32 +0000 |
---|---|---|
committer | Julien Dramaix <julien.dramaix@gmail.com> | 2012-01-09 15:34:32 +0000 |
commit | a80cfbe63a4997b40ca3125577ccce20eb2eab64 (patch) | |
tree | c8ea5063e5eb6f0922605164a88e52728863f991 | |
parent | 1c0cf16293c3b7d295b0fce2de8ae33ce65f35dc (diff) | |
download | gwtquery-a80cfbe63a4997b40ca3125577ccce20eb2eab64.tar.gz gwtquery-a80cfbe63a4997b40ca3125577ccce20eb2eab64.zip |
add enum support
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java | 14 |
1 files 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
|