Fix rest of Enum issues

This commit is contained in:
Travis Burtrum 2018-01-15 11:56:06 -05:00
parent ebccf0a0e2
commit 2580de8f42
3 changed files with 18 additions and 12 deletions

View File

@ -327,11 +327,7 @@ public class CompilingRowToObjectMapper<K, T> extends RowToObjectMapper<K, T> {
return _returnTypeClass.cast(val);
}
*/
// we could actually pull from first row like above and test it first and fail now, but maybe just failing during compilation is enough?
java.append("final ").append(tType).append(" ret = (").append(tType).append(") ");
extractColumnValueString(java, 1, typeId, _returnTypeClass.getCanonicalName());
java.append(";\n");
return;
// todo: we could actually pull from first row like above and test it first, but for now we will fall-through to field mappings...
}
} catch (Exception e) {
throw new MapperException(e.getMessage(), e);

View File

@ -524,17 +524,19 @@ public class RowToObjectMapper<K, T> extends AbstractRowMapper<K, T> {
+ "stripped of '_' and compared if no match is found with them.");
}
_fields[i] = f;
final Class<?> type;
if (f instanceof Field) {
final Field field = (Field) f;
_fields[i] = modField(field, i);
_fieldTypes[i] = _tmf.getTypeId(field.getType());
if(_fieldTypes[i] == TypeMappingsFactory.TYPE_ENUM) {
@SuppressWarnings("unchecked")
final Class<? extends Enum> noWarnings = (Class<? extends Enum>) field.getType();
_fieldClasses[i] = noWarnings;
}
type = field.getType();
} else {
_fieldTypes[i] = _tmf.getTypeId(((Method) f).getParameterTypes()[0]);
type = ((Method) f).getParameterTypes()[0];
}
_fieldTypes[i] = _tmf.getTypeId(type);
if(_fieldTypes[i] == TypeMappingsFactory.TYPE_ENUM) {
@SuppressWarnings("unchecked")
final Class<? extends Enum> noWarnings = (Class<? extends Enum>) type;
_fieldClasses[i] = noWarnings;
}
}
}

View File

@ -37,6 +37,14 @@ public class EnumPerson implements Person {
return lastName;
}
public void setFirstName(final FirstName firstName) {
this.firstName = firstName;
}
public void setLastName(final String lastName) {
this.lastName = lastName;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;