WIP json refactor - initial tidy

This commit is contained in:
Rob Bygrave committed 2014-11-05 23:15:09 +13:00
1 parent 0ceda6406e
commit b313809894
29 files changed
+1301 -1001

No files matched your search

@@ -25,8 +25,7 @@ import com.avaje.ebeaninternal.server.el.ElPropertyValue;
import com.avaje.ebeaninternal.server.query.SplitName;
import com.avaje.ebeaninternal.server.query.SqlBeanLoad;
import com.avaje.ebeaninternal.server.query.SqlJoinType;
import com.avaje.ebeaninternal.server.text.json.ReadJsonContext;
import com.avaje.ebeaninternal.server.text.json.WriteJsonContext;
import com.avaje.ebeaninternal.server.text.json.WriteJson;
/**
* Property mapped to a joined bean.
@@ -832,25 +831,23 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> {
}
@Override
public void jsonWrite(WriteJsonContext ctx, EntityBean bean) {
public void jsonWrite(WriteJson writeJson, EntityBean bean) {
Object value = getValueIntercept(bean);
if (value == null){
ctx.beginAssocOneIsNull(name);
writeJson.gen().writeNull(name);
} else {
if (ctx.isParentBean(value)){
if (writeJson.isParentBean(value)){
// bi-directional and already rendered parent
} else {
// Hmmm, not writing complex non-entity bean
if (value instanceof EntityBean) {
ctx.pushParentBean(bean);
ctx.beginAssocOne(name);
writeJson.beginAssocOne(name, bean);
BeanDescriptor<?> refDesc = descriptor.getBeanDescriptor(value.getClass());
refDesc.jsonWrite(ctx, (EntityBean)value);
ctx.endAssocOne();
ctx.popParentBean();
refDesc.jsonWrite(writeJson, (EntityBean)value, name);
writeJson.endAssocOne();
}
}
}