Making a small change to a Java protocol buffers object

前端 未结 1 2024
一生所求
一生所求 2021-02-05 03:36

I want to make a small change, deep in tree of Java protocol buffer objects.

I can use the .getBuilder() method to make a new object that is a clone of an o

1条回答
  •  逝去的感伤
    2021-02-05 03:49

    Another option is (I think; it's been a while):

    Foo.Builder fooBuilder = foo.toBuilder();
    fooBuilder.getBarBuilder().getBazBuilder().getQuuxBuilder()
        .setNewThing(newThing);
    newFoo = fooBuilder.build();
    

    Note that this isn't any more efficient; you're still making copies of foo, bar, baz, and quux.

    0 讨论(0)
提交回复
热议问题