title: Handling null values in protobuffers
body: <p>I am working on something which fetches data from database and constructs protobuff message. Given the possibility that null values can be fetched from the database for certain fields , I will get Null-pointer exception while trying to construct the protobuff message. Getting to know that null is not supported in protobuffs from the thread <a href="http://code.google.com/p/protobuf/issues/detail?id=57" rel="noreferrer">http://code.google.com/p/protobuf/issues/detail?id=57</a>, I am wondering whether the only other way to handle NPE getting thrown is to insert manual checks into the java file corresponding to the proto like below!</p>
  
  <pre><code>message ProtoPerson{
      optional string firstName = 1;
      optional string lastName = 2;
      optional string address1 = 3;
  }
  
  ProtoPerson.Builder builder = ProtoPerson.Builder.newBuilder();
  if (p.getFirstName() != null) builder.setFirstName(p.getFirstName());
  if (p.getLastName() != null) builder.setLastName(p.getLastName());
  if (p.getAddress1() != null) builder.setAddress1(p.getAddress1());
  ...
  </code></pre>
  
  <p>So can someone please clarify whether there is any other possible efficient way to handle the null values during protobuff construction??</p>