c = mf.isSingleValue() ? mf.getConcreteType() : mf.getSubClass();
}
try {
return createInstance(c, dbObj);
} catch (RuntimeException e) {
final ConstructorArgs argAnn = mf.getAnnotation(ConstructorArgs.class);
if (argAnn == null) {
throw e;
}
//TODO: now that we have a mapper, get the arg types that way by getting the fields by name. + Validate names
final Object[] args = new Object[argAnn.value().length];
final Class[] argTypes = new Class[argAnn.value().length];
for (int i = 0; i < argAnn.value().length; i++) {
//TODO: run converters and stuff against these. Kinda like the List of List stuff,
// using a fake MappedField to hold the value
final Object val = dbObj.get(argAnn.value()[i]);
args[i] = val;
argTypes[i] = val.getClass();
}
try {
final Constructor constructor = c.getDeclaredConstructor(argTypes);