createMapBlock.assign(mapVar, fieldAccessorField.invoke("getObject").arg(builder.getXSR()).arg(builder.getReadContextVar()).arg(beanVar));
}
} else {
Method getter = property.getGetter() ;
if (!isPrivate(getter)) {
JTryBlock tryGetter = createMapBlock._try();
tryGetter.body().assign(mapVar, beanVar.invoke(getter.getName()));
JCatchBlock catchException = tryGetter._catch(context.toJClass(Exception.class));
catchException.body().invoke(builder.getReadContextVar(), "getterError")
.arg(builder.getXSR())
.arg(context.dotclass(property.getBean().getType()))
.arg(getter.getName())
.arg(catchException.param("e"));
catchException.body()._continue();
} else {
JFieldVar propertyAccessorField = builder.getPrivatePropertyAccessor(property.getGetter(), property.getSetter(), property.getName());
createMapBlock.assign(mapVar, propertyAccessorField.invoke("getObject").arg(builder.getXSR()).arg(builder.getReadContextVar()).arg(beanVar));
}
}
// if (map != null) {
// map.clear();
JConditional arrayFoundCondition = createMapBlock._if(mapVar.ne(JExpr._null()));
arrayFoundCondition._then().invoke(mapVar, "clear");
// } else {
// map = new ArrayList();
JType mapType = getMapClass(property.getType(), property.getComponentType());
if (mapType != null) {
arrayFoundCondition._else().assign(mapVar, JExpr._new(mapType));
} else {
arrayFoundCondition._else().invoke(builder.getReadContextVar(), "uncreatableMap")
.arg(builder.getXSR())
.arg(context.dotclass(property.getBean().getType()))
.arg(property.getName())
.arg(context.dotclass(property.getType()));
arrayFoundCondition._else()._continue();
}
}
// }
// }
// collection.add(item);
block.add(mapVar.invoke("put").arg(builder.getAttributeVar().invoke("getName")).arg(toSet));
//
// set the map into the bean at the bottom of the method
//
// if (map != null) {
// bean.setAnyAttribute(map);
// }
if (property.getField() != null) {
Field field = property.getField();
JBlock assignMapBlock = builder.getReadTailBlock()._if(mapVar.ne(JExpr._null()))._then();
if (!isPrivate(field)) {
assignMapBlock.assign(beanVar.ref(field.getName()), mapVar);
} else {
JFieldVar fieldAccessorField = builder.getPrivateFieldAccessor(field);
assignMapBlock.add(fieldAccessorField.invoke("setObject").arg(builder.getXSR()).arg(builder.getReadContextVar()).arg(beanVar).arg(mapVar));
}
} else {
// if there is no setter method, the map is not assigned into the class
// this assumes that the getter returned the a map instance and held on to a reference
Method setter = property.getSetter();
if (setter != null) {
JBlock assignMapBlock = builder.getReadTailBlock()._if(mapVar.ne(JExpr._null()))._then();
if (!isPrivate(setter)) {
JTryBlock trySetter = assignMapBlock._try();
trySetter.body().add(beanVar.invoke(setter.getName()).arg(mapVar));
JCatchBlock catchException = trySetter._catch(context.toJClass(Exception.class));
catchException.body().invoke(builder.getReadContextVar(), "setterError")
.arg(builder.getXSR())
.arg(context.dotclass(property.getBean().getType()))
.arg(setter.getName())
.arg(context.dotclass(setter.getParameterTypes()[0]))