has<Field>() methods in Java

12 views
Skip to first unread message

Janac Meena

unread,
Jul 11, 2019, 4:54:26 PM7/11/19
to Protocol Buffers
Hello,

I see in the documentation that there is a way to check for the existence of a field in a message, i.e. 

message Foo {
 string name = 1;

In my Java code, I was hoping to do 

// Assuming object "foo" has been initialized

if (foo.hasName()) {
// do stuff
}

But I am unable to find the hasX() methods.

What's going on? 

Ilia Mirkin

unread,
Jul 11, 2019, 5:09:20 PM7/11/19
to Janac Meena, Protocol Buffers
These are gone in proto3. The has* stuff is available with proto2.
> --
> You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
> To post to this group, send email to prot...@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/1d700a63-f677-4c56-8c47-fa50d3d5468f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages