When you use the protoc command to create a java object, it will create a Foo object that will have its own build method on it.
You end up with something like this
Builder builder = Package.Foo.newBuilder();
builder.addAll(new ArrayList<Bar>());
builder.build();
To add individual objects, you can do something like this.
Bar bar = new Bar();
builder.addBar(bar);
builder.build();
Edited using the use case you requested.
Venki source
share