More enum support

This commit is contained in:
Travis Burtrum 2018-03-09 00:09:01 -05:00
parent a6c5fc7b52
commit ba7fb733b2
3 changed files with 6 additions and 2 deletions

View File

@ -93,6 +93,10 @@ public class CompileTimeResultSetMapper {
toArray(w, keys, componentType, maxRows, cal, cleaner, reflectionFields);
} else if (types.isAssignable(returnTypeMirror, collectionType)) {
final List<? extends TypeMirror> typeArguments = ((DeclaredType) returnTypeMirror).getTypeArguments();
if(typeArguments.isEmpty()) {
JdbcMapperProcessor.getMessager().printMessage(Diagnostic.Kind.ERROR, "Collection type must have a generic type argument", eeMethod);
return true;
}
toCollection(w, keys, returnTypeMirror, typeArguments.get(0), maxRows, cal, cleaner, reflectionFields);
} else if (types.isAssignable(returnTypeMirror, mapType) && eeMethod.getAnnotation(JdbcMapper.SingleRow.class) == null) {
final List<? extends TypeMirror> typeArguments = ((DeclaredType) returnTypeMirror).getTypeArguments();

View File

@ -729,7 +729,7 @@ public class JdbcMapperProcessor extends AbstractProcessor {
// we are going to put most common ones up top so it should execute faster normally
// todo: avoid string concat here
if (method == null)
if (o.getKind().isPrimitive() || types.isAssignable(o, stringType) || types.isAssignable(o, numberType)) {
if (o.getKind().isPrimitive() || types.isAssignable(o, stringType) || types.isAssignable(o, numberType) || types.isAssignable(o, enumType)) {
method = "Object";
// java.util.Date support, put it in a Timestamp
} else if (types.isAssignable(o, utilDateType)) {

View File

@ -127,7 +127,7 @@ public class SimpleSQLChecker implements SQLChecker {
}
// end special behavior
// we are going to put most common ones up top so it should execute faster normally
if (types.isAssignable(o, stringType)) {
if (types.isAssignable(o, stringType) || types.isAssignable(o, enumType)) { // todo: hack for enum, might try to get one of the options? is it even possible?
return defaultString;
} else if (o.getKind().isPrimitive() || types.isAssignable(o, numberType)) {
switch (o.getKind()) {