package com.google.protobuf;

import V.C0629x;
import com.google.crypto.tink.shaded.protobuf.C1256d;
import java.io.IOException;

/* JADX INFO: loaded from: classes3.dex */
public abstract class G extends AbstractC1296b {
    private final L defaultInstance;
    protected L instance;

    public G(L l) {
        this.defaultInstance = l;
        if (l.isMutable()) {
            throw new IllegalArgumentException("Default instance must be immutable.");
        }
        this.instance = l.newMutableInstance();
    }

    public final void copyOnWrite() {
        if (this.instance.isMutable()) {
            return;
        }
        copyOnWriteInternal();
    }

    public void copyOnWriteInternal() {
        L lNewMutableInstance = this.defaultInstance.newMutableInstance();
        D0.f14169c.b(lNewMutableInstance).a(lNewMutableInstance, this.instance);
        this.instance = lNewMutableInstance;
    }

    @Override // com.google.protobuf.InterfaceC1334u0
    public final boolean isInitialized() {
        return L.isInitialized(this.instance, false);
    }

    /* JADX INFO: renamed from: build, reason: merged with bridge method [inline-methods] */
    public final L m359build() {
        L lBuildPartial = buildPartial();
        if (lBuildPartial.isInitialized()) {
            return lBuildPartial;
        }
        throw AbstractC1296b.newUninitializedMessageException(lBuildPartial);
    }

    @Override // com.google.protobuf.InterfaceC1330s0
    public L buildPartial() {
        if (!this.instance.isMutable()) {
            return this.instance;
        }
        this.instance.makeImmutable();
        return this.instance;
    }

    /* JADX INFO: renamed from: clear, reason: merged with bridge method [inline-methods] */
    public final G m360clear() {
        if (this.defaultInstance.isMutable()) {
            throw new IllegalArgumentException("Default instance must be immutable.");
        }
        this.instance = this.defaultInstance.newMutableInstance();
        return this;
    }

    @Override // com.google.protobuf.InterfaceC1334u0
    public L getDefaultInstanceForType() {
        return this.defaultInstance;
    }

    @Override // com.google.protobuf.AbstractC1296b
    public G internalMergeFrom(L l) {
        return mergeFrom(l);
    }

    /* JADX INFO: renamed from: clone, reason: merged with bridge method [inline-methods] and merged with bridge method [inline-methods] and merged with bridge method [inline-methods] */
    public G m363clone() {
        G gNewBuilderForType = getDefaultInstanceForType().newBuilderForType();
        gNewBuilderForType.instance = buildPartial();
        return gNewBuilderForType;
    }

    public G mergeFrom(L l) {
        if (getDefaultInstanceForType().equals(l)) {
            return this;
        }
        copyOnWrite();
        L l6 = this.instance;
        D0.f14169c.b(l6).a(l6, l);
        return this;
    }

    @Override // com.google.protobuf.AbstractC1296b
    /* JADX INFO: renamed from: mergeFrom, reason: merged with bridge method [inline-methods] */
    public G m366mergeFrom(byte[] bArr, int i6, int i7, C1343z c1343z) throws C1297b0 {
        copyOnWrite();
        try {
            D0.f14169c.b(this.instance).j(this.instance, bArr, i6, i6 + i7, new C1256d(c1343z));
            return this;
        } catch (C1297b0 e6) {
            throw e6;
        } catch (IOException e7) {
            throw new RuntimeException("Reading from byte array should not throw IOException.", e7);
        } catch (IndexOutOfBoundsException unused) {
            throw C1297b0.h();
        }
    }

    @Override // com.google.protobuf.AbstractC1296b
    /* JADX INFO: renamed from: mergeFrom, reason: merged with bridge method [inline-methods] */
    public G m365mergeFrom(byte[] bArr, int i6, int i7) {
        return m366mergeFrom(bArr, i6, i7, C1343z.a());
    }

    @Override // com.google.protobuf.AbstractC1296b
    /* JADX INFO: renamed from: mergeFrom, reason: merged with bridge method [inline-methods] */
    public G m364mergeFrom(AbstractC1329s abstractC1329s, C1343z c1343z) throws IOException {
        copyOnWrite();
        try {
            J0 j0B = D0.f14169c.b(this.instance);
            L l = this.instance;
            C0629x c0629x = abstractC1329s.f14353c;
            if (c0629x == null) {
                c0629x = new C0629x(abstractC1329s);
            }
            j0B.f(l, c0629x, c1343z);
            return this;
        } catch (RuntimeException e6) {
            if (e6.getCause() instanceof IOException) {
                throw ((IOException) e6.getCause());
            }
            throw e6;
        }
    }
}
