com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl
@Override
public boolean visitValueProperty(String propertyName, Object value, PropertyContext ctx) {
if (value != null && !value.equals(ValueCodex.getUninitializedFieldValue(ctx.getType()))) {
encodeProperty(propertyName, value, ctx);
}
return false;
}
If I create an AutoBean with set/get for an native number type, say int, and set that value to zero then it is not in the result of AutoBeanCodex.encode(bean).getPayload()
So if the bean only contains that field and it is set to zero the resulting payload is {}
I would think it should be {"myIntValue":0} shouldn't it?
public class AutoBeanPoc implements EntryPoint {
private PocBeanFactory beanFactory = GWT.create(PocBeanFactory.class);
interface PocBeanFactory extends AutoBeanFactory {
AutoBean<PocBean> pocBean();
}
interface PocBean {
void setIntValue(int intValue);
int getIntValue();
}
static class PocJsObject extends JavaScriptObject {
protected PocJsObject() { }
public final native int getIntValue() /*-{
if(typeof(this.intValue) == "undefined") {
throw "intValue is undefined"
}
return this.intValue;
}-*/;
}
@Override
public void onModuleLoad() {
PocBean bean = beanFactory.pocBean().as();
bean.setIntValue(0);
String payload = AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(bean)).getPayload();
PocJsObject jsObj = JsonUtils.safeEval(payload);
try {
RootPanel.get().add(new HTML("intValue is " + jsObj.getIntValue()));
}
catch (JavaScriptException e) {
RootPanel.get().add(new HTML(e.toString()));
}
}
}
I would be interested to hear the communities thoughts before I take the plunge and file a report.