throw new MarshallingException("no marshaller for type: " + type);
}
}
if (instantiationMapping instanceof ConstructorMapping) {
ConstructorMapping mapping = (ConstructorMapping) instantiationMapping;
MetaConstructor constructor = mapping.getMember();
if (constructor.isPublic()) {
tryBuilder.append(Stmt.declareVariable(toMap).named("entity")
.initializeWith(Stmt.newObject(toMap)
.withParameters(constructorParameters.toArray(new Object[constructorParameters.size()]))));
}
else {
PrivateAccessUtil.addPrivateAccessStubs(gwtTarget, context.getClassStructureBuilder(), constructor);
tryBuilder.append(Stmt.declareVariable(toMap).named("entity")
.initializeWith(
Stmt.invokeStatic(
context.getClassStructureBuilder().getClassDefinition(),
PrivateAccessUtil.getPrivateMethodName(constructor),
constructorParameters.toArray(new Object[constructorParameters.size()]))));
}
}
else if (instantiationMapping instanceof FactoryMapping) {
tryBuilder.append(Stmt.declareVariable(toMap).named("entity")
.initializeWith(Stmt.invokeStatic(toMap, ((FactoryMapping) instantiationMapping).getMember().getName(),
constructorParameters.toArray(new Object[constructorParameters.size()]))));
}
}
else {
// use default constructor
tryBuilder.append(Stmt.declareVariable(toMap).named("entity").initializeWith(Stmt.nestedCall(Stmt.newObject(toMap))));
}
tryBuilder.append(loadVariable("a1").invoke("recordObjectHash",
loadVariable("objId"), loadVariable("entity")));
}
/**
* Start binding of fields here.
*/
for (MemberMapping memberMapping : mapping.getMemberMappings()) {
if (!memberMapping.canWrite()) continue;
Statement bindingStatement;
Statement val;
if (memberMapping.getType().isArray()) {