Commits

Stephen McKamey committed 958e54b

quick fix for annoying generic type warning

  • Participants
  • Parent commits 52c80ce

Comments (0)

Files changed (2)

duel-compiler/src/main/java/org/duelengine/duel/codegen/JavaCodeGen.java

 		} else {
 			Package pkg = type.getPackage();
 			String pkgName = (pkg == null) ? null : pkg.getName();
-			if (pkgName == null || "java.lang".equals(pkgName) || "java.io".equals(pkgName) /*|| "java.util".equals(pkgName)*/ || DUEL_PACKAGE.equals(pkgName)) {
+			if (pkgName == null || "java.lang".equals(pkgName) || "java.io".equals(pkgName) || DUEL_PACKAGE.equals(pkgName)) {
 				typeName = type.getSimpleName();
 			} else {
 				typeName = type.getName().replace('$', '.');
+				if (type == Collection.class || type == Iterator.class) {
+					// quick fix for generic types that have annoying warnings
+					typeName += "<?>";
+
+				} else if (type == Map.Entry.class) {
+					// quick fix for generic types that have annoying warnings
+					typeName += "<?,?>";
+				}
 			}
 		}
 		output.append(typeName);

duel-compiler/src/test/java/org/duelengine/duel/codegen/JavaCodeGenTest.java

 			"\t@Override\n"+
 			"\tprotected void render(DuelContext context, Object data, int index, int count, String key) throws IOException {\n"+
 			"\t\tthis.write(context, \"<div>\");\n"+
-			"\t\tjava.util.Collection items_1 = DuelData.coerceCollection(this.getProperty(data, \"items\"));\n"+
+			"\t\tjava.util.Collection<?> items_1 = DuelData.coerceCollection(this.getProperty(data, \"items\"));\n"+
 			"\t\tint index_2 = 0,\n" +
 			"\t\t\tcount_3 = items_1.size();\n"+
-			"\t\tfor (java.util.Iterator iterator_4=items_1.iterator(); iterator_4.hasNext(); index_2++) {\n"+
+			"\t\tfor (java.util.Iterator<?> iterator_4=items_1.iterator(); iterator_4.hasNext(); index_2++) {\n"+
 			"\t\t\tthis.render_2(context, iterator_4.next(), index_2, count_3, null);\n"+
 			"\t\t}\n"+
 			"\t\tthis.write(context, \"</div>\");\n"+
 			"\t@Override\n"+
 			"\tprotected void render(DuelContext context, Object data, int index, int count, String key) throws IOException {\n"+
 			"\t\tthis.write(context, \"<div>\");\n"+
-			"\t\tjava.util.Collection items_1 = DuelData.coerceMap(this.getProperty(data, \"foo\"));\n"+
+			"\t\tjava.util.Collection<?> items_1 = DuelData.coerceMap(this.getProperty(data, \"foo\"));\n"+
 			"\t\tint index_2 = 0,\n"+
 			"\t\t\tcount_3 = items_1.size();\n"+
-			"\t\tfor (java.util.Iterator iterator_4=items_1.iterator(); iterator_4.hasNext(); index_2++) {\n"+
-			"\t\t\tjava.util.Map.Entry entry_5 = iterator_4.next();\n"+
+			"\t\tfor (java.util.Iterator<?> iterator_4=items_1.iterator(); iterator_4.hasNext(); index_2++) {\n"+
+			"\t\t\tjava.util.Map.Entry<?,?> entry_5 = iterator_4.next();\n"+
 			"\t\t\tthis.render_2(context, entry_5.getValue(), index_2, count_3, entry_5.getKey());\n"+
 			"\t\t}\n"+
 			"\t\tthis.write(context, \"</div>\");\n"+