title: How to Mask certain fields in Protobuf
body: <p>I couldnt find a way to mask certain fields in protobuf structure. I did read about the FieldMaskUtil and tried few examples but it seems to do the reverse i.e copy fields which are mentioned in FieldMask which is different from what i wanted. Here's the sample structure and corresponding Test code.</p>
  
  <p>Proto:</p>
  
  <pre><code>syntax = "proto3";
  
  package model;
  
  option java_package = "test.demo.services.protobuf.customer.model";
  option java_outer_classname = "CustomerProto";
  
  message Accounts {
    repeated Account account = 1;
  }
  
  message Account {
  
    int32 id = 1;
    string number = 2;
    int32 customer_id = 3;
  
  }
  
   message Customers {
     repeated Customer customers = 1;
  }
  
  message Customer {
  
    int32 id = 1;
    string pesel = 2;
    string name = 3;
    CustomerType type = 4;
    repeated Account accounts = 5;
  
    enum CustomerType {
      INDIVIDUAL = 0;
      COMPANY = 1;
    }
  
  }
  </code></pre>
  
  <p>Here's sample test code</p>
  
  <pre><code>package test.demo.services.protobuf.customer.model;
  
  import org.junit.Test;
  import test.demo.services.protobuf.customer.model.CustomerProto.Customer;
  import com.google.protobuf.util.FieldMaskUtil;
  
  
  public class TestMerge {
  
  
    @Test
    public void eraseFields() {
  
          Customer request = Customer.newBuilder().setId(10).setPesel("12345").setName("Harry Alto").build();
      // Erase name
        Customer.Builder modifieldRequest = Customer.newBuilder();
        FieldMaskUtil.merge(FieldMaskUtil.fromString("name"), request, modifieldRequest);
        System.out.println( modifieldRequest.build().toString());
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here's the output:</p>
  
  <pre><code>name: "Harry Alto"
  </code></pre>
  
  <p>What i would have expected is to print everything other than name</p>
  
  <pre><code>id: 10
  pesel: "12345"
  </code></pre>
  
  <p>Is there a way to do what i want</p>