insitu
insitu

Reputation: 4698

Can I have protoc generate an array of int in Java?

Using protocol buffers compiler version 2.6.0, a field declared as

repeated int32 values = 1;

generates in Java a field like:

private java.util.List<java.lang.Integer> values;

I would like to generate:

private int[] values;

along with compatible setters/getters. Is this possible out of the box?

Upvotes: 0

Views: 299

Answers (1)

waltersu
waltersu

Reputation: 1231

No there isn't. You have to convert between array and list by yourself.

If it helps, take a look at Hadoop project. It has a lots of static methods to help the conversion between java object and proto object. PBHelperClient.java. As you can see, there's a lots of conversion between array and list.

Upvotes: 1

Related Questions