Пример #1
0
 @Override
 public Builder mergeFrom(Message other) {
   if (other instanceof DynamicMessage) {
     // This should be somewhat faster than calling super.mergeFrom().
     DynamicMessage otherDynamicMessage = (DynamicMessage) other;
     if (otherDynamicMessage.type != type) {
       throw new IllegalArgumentException(
           "mergeFrom(Message) can only merge messages of the same type.");
     }
     ensureIsMutable();
     fields.mergeFrom(otherDynamicMessage.fields);
     mergeUnknownFields(otherDynamicMessage.unknownFields);
     for (int i = 0; i < oneofCases.length; i++) {
       if (oneofCases[i] == null) {
         oneofCases[i] = otherDynamicMessage.oneofCases[i];
       } else {
         if ((otherDynamicMessage.oneofCases[i] != null)
             && (oneofCases[i] != otherDynamicMessage.oneofCases[i])) {
           fields.clearField(oneofCases[i]);
           oneofCases[i] = otherDynamicMessage.oneofCases[i];
         }
       }
     }
     return this;
   } else {
     return super.mergeFrom(other);
   }
 }
 public Builder mergeFrom(Message other) {
   if (other instanceof DynamicMessage) {
     // This should be somewhat faster than calling super.mergeFrom().
     DynamicMessage otherDynamicMessage = (DynamicMessage) other;
     if (otherDynamicMessage.type != type) {
       throw new IllegalArgumentException(
           "mergeFrom(Message) can only merge messages of the same type.");
     }
     fields.mergeFrom(otherDynamicMessage.fields);
     mergeUnknownFields(otherDynamicMessage.unknownFields);
     return this;
   } else {
     return super.mergeFrom(other);
   }
 }