This behavior is to be expected, because in proto3 there is no notion of field presence for primitive type fields (more about this here <https://developers.google.com/protocol-buffers/docs/proto3#default>). Proto3 does not make a distinction between that field being unset and being set to its default value of 0.
On Wed, Jan 4, 2017 at 10:10 PM, <[email protected]> wrote: > public class Test { > public static void main(String[] args) throws Exception { > > Device device = Device.newBuilder() > .setMeterAperture(0) > .build(); > // device.getMeterAlarm(); > > System.out.println(device.hasField(Device.getDescriptor( > ).findFieldByNumber(Device.METER_APERTURE_FIELD_NUMBER))); > // PRINT false > } > } > > hasField can't return true; > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
