public Builder clearField(FieldDescriptor field) { verifyContainingType(field); ensureIsMutable(); OneofDescriptor oneofDescriptor = field.getContainingOneof(); if (oneofDescriptor != null) { int index = oneofDescriptor.getIndex(); if (oneofCases[index] == field) { oneofCases[index] = null; } } fields.clearField(field); return this; }
public Builder setField(FieldDescriptor field, Object value) { verifyContainingType(field); ensureIsMutable(); if (field.getType() == FieldDescriptor.Type.ENUM) { verifyEnumType(field, value); } OneofDescriptor oneofDescriptor = field.getContainingOneof(); if (oneofDescriptor != null) { int index = oneofDescriptor.getIndex(); FieldDescriptor oldField = oneofCases[index]; if ((oldField != null) && (oldField != field)) { fields.clearField(oldField); } oneofCases[index] = field; } fields.setField(field, value); return this; }