Class cls,
Class parentCls,
RuntimeClassInfo info,
boolean wrap) {
JCodeModel model = classBuilder.getCodeModel();
CodeBody body = classBuilder.getBody();
JType type = model._ref(cls);
JBlock xsiNilReturnBlock = body.getBlock()._if(JExpr.direct("reader").invoke("isXsiNil"))._then();
// Method factoryMethod = info.getFactoryMethod();
JVar var = body.decl(type, info.getClazz().getSimpleName(), JExpr._new(type));
if (wrap) {
JType jaxbElementType = model._ref(JAXBElement.class);
JType qnameType = model._ref(QName.class);
JVar qname = body.getBlock().decl(qnameType, "_xname", JExpr.direct("reader").invoke("getName"));
body._return(jaxbElementType,
JExpr._new(jaxbElementType)
.arg(qname).arg(JExpr.dotclass((JClass) type)).arg(var));
xsiNilReturnBlock._return(JExpr._null());
} else if (parentCls == null) {
body._return(var);
xsiNilReturnBlock._return(JExpr._null());
} else {
xsiNilReturnBlock._return();
}