From 6897043392b713a2d29d6e9c1d4cf99706cf2fba Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Wed, 7 Jun 2017 03:00:29 -0400 Subject: [PATCH] Fix compilation with java 6 --- .../codegen/CompileTimeResultSetMapper.java | 26 +++++++------------ .../codegen/CompileTimeRowToObjectMapper.java | 4 +-- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java b/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java index bd9e0ed..9553d1e 100644 --- a/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java +++ b/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeResultSetMapper.java @@ -38,13 +38,12 @@ public class CompileTimeResultSetMapper { listIteratorType = types.getDeclaredType(elements.getTypeElement(ListIterator.class.getCanonicalName()), types.getWildcardType(null, null)); } - @SuppressWarnings({"unchecked"}) - public static String getConcreteClassCanonicalName(final TypeMirror returnType, final Class defaultConcreteClass) { + public static String getConcreteClassCanonicalName(final TypeMirror returnType, final Class defaultConcreteClass) { final Set modifiers = ((DeclaredType) returnType).asElement().getModifiers(); if (modifiers.contains(Modifier.ABSTRACT)) { // todo: no interface? try { - final Class concrete = (Class) ResultSetMapper.interfaceToConcrete.get(typeMirrorToClass(returnType)); - return (concrete == null ? (Class) defaultConcreteClass : concrete).getCanonicalName(); + final Class concrete = ResultSetMapper.interfaceToConcrete.get(typeMirrorToClass(returnType)); + return (concrete == null ? defaultConcreteClass : concrete).getCanonicalName(); } catch (ClassNotFoundException e) { // ignore? } @@ -52,7 +51,6 @@ public class CompileTimeResultSetMapper { return typeMirrorStringNoGenerics(returnType); } - @SuppressWarnings({"unchecked"}) public void mapToResultType(final Writer w, final String[] keys, final ExecutableElement eeMethod, final int arrayMaxLength, final Calendar cal) throws IOException, NoSuchMethodException, ClassNotFoundException { //final Method m = fromExecutableElement(eeMethod); //final Class returnType = m.getReturnType(); @@ -90,7 +88,6 @@ public class CompileTimeResultSetMapper { } } - @SuppressWarnings("unchecked") public CompileTimeRowToObjectMapper getRowMapper(final String[] keys, TypeMirror returnTypeClass, Calendar cal, TypeMirror mapValType, TypeMirror mapKeyType) { return new CompileTimeRowToObjectMapper(keys, returnTypeClass, cal, mapValType, mapKeyType); } @@ -105,8 +102,7 @@ public class CompileTimeResultSetMapper { w.write("\t\t\t\treturn ret;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n"); } - @SuppressWarnings("unchecked") - public , E> void writeCollection(final Writer w, final String[] keys, final String returnTypeString, final String concreteTypeString, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { + public void writeCollection(final Writer w, final String[] keys, final String returnTypeString, final String concreteTypeString, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { w.write("\t\t\tfinal "); w.write(returnTypeString); w.write(" _colret = new "); @@ -117,13 +113,13 @@ public class CompileTimeResultSetMapper { w.write("\t\t\t\t_colret.add(ret);\n\t\t\t}\n"); } - public , E> void toCollection(final Writer w, final String[] keys, final TypeMirror collectionTypeMirror, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { + public void toCollection(final Writer w, final String[] keys, final TypeMirror collectionTypeMirror, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { final String collectionType = getConcreteClassCanonicalName(collectionTypeMirror, ArrayList.class); writeCollection(w, keys, collectionTypeMirror.toString(), collectionType, componentTypeMirror, arrayMaxLength, cal); w.write("\t\t\treturn _colret;\n"); } - public void toArray(final Writer w, final String[] keys, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { + public void toArray(final Writer w, final String[] keys, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { final String returnTypeString = componentTypeMirror.toString(); writeCollection(w, keys, "java.util.List<" + returnTypeString + ">", "java.util.ArrayList", componentTypeMirror, arrayMaxLength, cal); w.write("\t\t\treturn _colret.toArray(new "); @@ -131,20 +127,19 @@ public class CompileTimeResultSetMapper { w.write("[_colret.size()]);\n"); } - public void toListIterator(final Writer w, final String[] keys, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { + public void toListIterator(final Writer w, final String[] keys, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { final String returnTypeString = componentTypeMirror.toString(); writeCollection(w, keys, "java.util.List<" + returnTypeString + ">", "java.util.ArrayList", componentTypeMirror, arrayMaxLength, cal); w.write("\t\t\treturn _colret.listIterator();\n"); } - public void toIterator(final Writer w, final String[] keys, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { + public void toIterator(final Writer w, final String[] keys, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { final String returnTypeString = componentTypeMirror.toString(); writeCollection(w, keys, "java.util.List<" + returnTypeString + ">", "java.util.ArrayList", componentTypeMirror, arrayMaxLength, cal); w.write("\t\t\treturn _colret.iterator();\n"); } - @SuppressWarnings("unchecked") - public , K, E> void toMap(final Writer w, final String[] keys, final TypeMirror mapTypeMirror, final TypeMirror mapKeyTypeMirror, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { + public void toMap(final Writer w, final String[] keys, final TypeMirror mapTypeMirror, final TypeMirror mapKeyTypeMirror, final TypeMirror componentTypeMirror, int arrayMaxLength, Calendar cal) throws IOException, ClassNotFoundException { final String mapType = getConcreteClassCanonicalName(mapTypeMirror, HashMap.class); final String returnTypeString = mapTypeMirror.toString(); w.write("\t\t\tfinal "); @@ -163,8 +158,7 @@ public class CompileTimeResultSetMapper { w.write("\t\t\treturn _colret;\n"); } - @SuppressWarnings("unchecked") - public , K, E extends Collection, C> void toMapCollection(final Writer w, final String[] keys, + public void toMapCollection(final Writer w, final String[] keys, final TypeMirror mapTypeMirror, final TypeMirror mapKeyTypeMirror, final TypeMirror collectionTypeMirror, diff --git a/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeRowToObjectMapper.java b/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeRowToObjectMapper.java index 104f219..061baab 100644 --- a/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeRowToObjectMapper.java +++ b/jdbcmapper/src/main/java/com/moparisthebest/jdbc/codegen/CompileTimeRowToObjectMapper.java @@ -390,11 +390,11 @@ public class CompileTimeRowToObjectMapper { } } - public static void extractColumnValueString(final Appendable java, final int index, final int resultType) throws IOException, ClassNotFoundException { + public void extractColumnValueString(final Appendable java, final int index, final int resultType) throws IOException, ClassNotFoundException { CompilingRowToObjectMapper.extractColumnValueString(java, index, resultType); } - public static void extractColumnValueString(final Appendable java, final int index, final TypeMirror resultType) throws IOException, ClassNotFoundException { + public void extractColumnValueString(final Appendable java, final int index, final TypeMirror resultType) throws IOException, ClassNotFoundException { CompilingRowToObjectMapper.extractColumnValueString(java, index, typeMirrorToClass(resultType)); } }