Is this still true? Or is there some way to tell PB that a field can potentially have null values?
If not, any suggestions on how to deal with fields that could potentially have null values? (Besides the obvious - don't set them, d'oh) *Asking 'cuz I have a fairly big class (~100 fields) and testing if each field is null before setting them in the PB Builder object is somewhat of a pain. On Oct 29, 10:29 am, Kenton Varda <[email protected]> wrote: > Protocol buffers has no concept of null. Fields cannot be set to null. You > can *clear* a field, like: > > builder.clearParamCountry(); > > This sets the field back to its default value (the empty string, unless you > declared some other default). Also, hasParamCountry() will return false > until you set it to something else. > > But you cannot set any field to null -- this will throw a > NullPointerException. > > > > On Thu, Oct 29, 2009 at 2:47 AM, micha <[email protected]> wrote: > > > Hi, > > > I have a message with a optionl field. > > > * optional string param_country = 6; > > > I would like to avoid the to check each attribute if its null or not, > > before setting it to the message. > > > In the net i found some code fragment of protobuf, that looked to me > > that setting this field to null > > > * .setParamCountry(someNullReference) > > > makes the Builder to call clearParamCountry(). > > > But I get a NullPoiterException .... -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
