Java Serialization Problems, while using guava Lists.transform

前端 未结 3 1770
萌比男神i
萌比男神i 2021-02-09 19:59

I had to serialize a complex object, but one of its component was non-serializable ( a third party graph object), so I created a custom serializable version of this Graph class

3条回答
  •  情深已故
    2021-02-09 20:03

    Lists.transform() does perform lazily as you suspected. You could do one of

    Lists.newArrayList(Lists.transform(...))
    

    or, if you want an immutable version,

    ImmutableList.copyOf(Lists.transform(...))
    

    and then serialize the resulting list.

提交回复
热议问题