package com.google.firebase.encoders.proto; import com.google.firebase.encoders.EncodingException; import com.google.firebase.encoders.FieldDescriptor; import com.google.firebase.encoders.ValueEncoderContext; /* loaded from: classes3.dex */ public class ProtobufValueEncoderContext implements ValueEncoderContext { public FieldDescriptor field; public final ProtobufDataEncoderContext objEncoderCtx; public boolean encoded = false; public boolean skipDefault = false; public void resetContext(FieldDescriptor fieldDescriptor, boolean z) { this.encoded = false; this.field = fieldDescriptor; this.skipDefault = z; } public ProtobufValueEncoderContext(ProtobufDataEncoderContext protobufDataEncoderContext) { this.objEncoderCtx = protobufDataEncoderContext; } public final void checkNotUsed() { if (this.encoded) { throw new EncodingException("Cannot encode a second value in the ValueEncoderContext"); } this.encoded = true; } @Override // com.google.firebase.encoders.ValueEncoderContext public ValueEncoderContext add(String str) { checkNotUsed(); this.objEncoderCtx.add(this.field, str, this.skipDefault); return this; } @Override // com.google.firebase.encoders.ValueEncoderContext public ValueEncoderContext add(boolean z) { checkNotUsed(); this.objEncoderCtx.add(this.field, z, this.skipDefault); return this; } }