列表<列表>在 AutoBeanFactory 中

发布于 2024-10-31 18:03:10 字数 1561 浏览 6 评论 0 原文

我在 RequestFactory 之外使用 AutoBeanFactory 在对象与 JSON 之间进行转换。它工作得非常好,但我刚刚添加了一种对象类型,它会因 NullPointerException 而导致代码崩溃,我不确定为什么。

我正在使用 GWT 2.2.0。

对象类:

public interface Policy
{
    public List<List<MyEnum>> getListsOfEnums();
    public void setListsOfEnums(List<List<MyEnum>> listOfLists);
}

工厂类:

public interface MyAutoBeanFactory extends AutoBeanFactory
{
    public AutoBean<Policy> policy();
}

当我调用 AutoBeanCodex.encode(anInstanceOfAnImplementationOfPolicy) 时,我得到一个 NullPointerException:

Caused by: java.lang.NullPointerException
    at com.google.gwt.autobean.shared.AutoBeanCodex$Encoder.encodeToStringBuilder(AutoBeanCodex.java:407)
    at com.google.gwt.autobean.shared.AutoBeanCodex$Encoder.visitCollectionProperty(AutoBeanCodex.java:310)
    at com.activegrade.shared.data.overallgradingpolicy.OverallGradingPolicyAutoBean.traverseProperties(OverallGradingPolicyAutoBean.java:264)
    at com.google.gwt.autobean.shared.impl.AbstractAutoBean.traverse(AbstractAutoBean.java:153)
    at com.google.gwt.autobean.shared.impl.AbstractAutoBean.accept(AbstractAutoBean.java:112)
    at com.google.gwt.autobean.shared.AutoBeanCodex.encodeForJsoPayload(AutoBeanCodex.java:546)
    at com.google.gwt.autobean.shared.AutoBeanCodex.encode(AutoBeanCodex.java:537)
... (my code)

看来 AutoBeanCodex 应该再次调用访问CollectionProperty,所​​以也许这是一个值得关注的错误谷歌的问题。另一方面,也许我做错了什么,或者这是明确不支持的。

我希望有人对此有一些经验,或者 BobV 有建议:)

I'm using an AutoBeanFactory outside of RequestFactory to transform objects to and from JSON. It's working really well, but I've just added a type of Object that is crashing the codex with a NullPointerException and I'm not sure why.

I'm using GWT 2.2.0.

The object class:

public interface Policy
{
    public List<List<MyEnum>> getListsOfEnums();
    public void setListsOfEnums(List<List<MyEnum>> listOfLists);
}

The factory class:

public interface MyAutoBeanFactory extends AutoBeanFactory
{
    public AutoBean<Policy> policy();
}

When I call AutoBeanCodex.encode(anInstanceOfAnImplementationOfPolicy), I get a NullPointerException:

Caused by: java.lang.NullPointerException
    at com.google.gwt.autobean.shared.AutoBeanCodex$Encoder.encodeToStringBuilder(AutoBeanCodex.java:407)
    at com.google.gwt.autobean.shared.AutoBeanCodex$Encoder.visitCollectionProperty(AutoBeanCodex.java:310)
    at com.activegrade.shared.data.overallgradingpolicy.OverallGradingPolicyAutoBean.traverseProperties(OverallGradingPolicyAutoBean.java:264)
    at com.google.gwt.autobean.shared.impl.AbstractAutoBean.traverse(AbstractAutoBean.java:153)
    at com.google.gwt.autobean.shared.impl.AbstractAutoBean.accept(AbstractAutoBean.java:112)
    at com.google.gwt.autobean.shared.AutoBeanCodex.encodeForJsoPayload(AutoBeanCodex.java:546)
    at com.google.gwt.autobean.shared.AutoBeanCodex.encode(AutoBeanCodex.java:537)
... (my code)

It seems like the AutoBeanCodex should make another call to visitCollectionProperty, so maybe this is a bug worthy of an issue with Google. On the other hand, maybe I'm doing something wrong, or this is expressly not supported.

I'm hoping someone has some experience with this, or that BobV has a suggestion :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南七夏 2024-11-07 18:03:10

GWT 2.2 分支后添加了对任意参数化集合序列化的支持。这应该可以在 2.3 版本分支或主干上工作。

Support for serialization of arbitrary parameterized collections was added after GWT 2.2 was branched. This should work in the 2.3 release branch or on trunk.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文