*/\r
package com.google.gwt.query.rebind;\r
\r
-import java.io.PrintWriter;\r
-import java.util.Collection;\r
-import java.util.HashSet;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
import com.google.gwt.core.client.JavaScriptObject;\r
import com.google.gwt.core.ext.Generator;\r
import com.google.gwt.core.ext.GeneratorContext;\r
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;\r
import com.google.gwt.user.rebind.SourceWriter;\r
\r
+import java.io.PrintWriter;\r
+import java.util.Collection;\r
+import java.util.HashSet;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
/**\r
*/\r
public class JsonBuilderGenerator extends Generator {\r
- static JClassType enumType;\r
+ \r
static JClassType functionType;\r
static JClassType jsonBuilderType;\r
static JClassType jsType;\r
jsType = oracle.findType(JavaScriptObject.class.getName());\r
listType = oracle.findType(List.class.getName());\r
functionType = oracle.findType(Function.class.getName());\r
- enumType = oracle.findType(Enum.class.getName());\r
\r
String t[] = generateClassName(clazz);\r
\r
} else {\r
sw.println("return Arrays.asList(" + ret + ");");\r
}\r
- } else if (isTypeAssignableTo(method.getReturnType(), enumType)){ \r
+ } else if (method.getReturnType().isEnum() != null){ \r
sw.println("return "+method.getReturnType().getQualifiedSourceName()+".valueOf(p.getStr(\"" + name + "\"));");\r
}else {\r
sw.println("System.err.println(\"JsonBuilderGenerator WARN: unknown return type " \r
JType type = params[0].getType();\r
JArrayType arr = type.isArray();\r
JParameterizedType list = type.isParameterized();\r
+ \r
sw.print("(" + type.getParameterizedQualifiedSourceName() + " a)");\r
sw.println("{");\r
sw.indent();\r
sw.println("p.setBoolean(\"" + name + "\", a);"); \r
} else if (type.getParameterizedQualifiedSourceName().matches("com.google.gwt.query.client.Function")) {\r
sw.println("p.setFunction(\"" + name + "\", a);"); \r
- } else {\r
+ } else if (type.isEnum() != null){ \r
+ sw.println("p.set(\"" + name + "\", a.name());");\r
+ }else {\r
sw.println("p.set(\"" + name + "\", a);");\r
}\r
if (!"void".equals(retType)) {\r