package com.google.protobuf;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
import java.util.List;
import java.util.logging.Logger;

/* JADX INFO: renamed from: com.google.protobuf.c, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC1298c implements InterfaceC1332t0 {
    protected int memoizedHashCode;

    @Deprecated
    public static <T> void addAll(Iterable<T> iterable, Collection<? super T> collection) {
        AbstractC1296b.addAll((Iterable) iterable, (List) collection);
    }

    public static void checkByteStringIsUtf8(AbstractC1320n abstractC1320n) {
        if (!abstractC1320n.r()) {
            throw new IllegalArgumentException("Byte string is not UTF-8.");
        }
    }

    public final String b(String str) {
        return "Serializing " + getClass().getName() + " to a " + str + " threw an IOException (should never happen).";
    }

    public abstract int getSerializedSize(J0 j02);

    public S0 newUninitializedMessageException() {
        return new S0();
    }

    @Override // com.google.protobuf.InterfaceC1332t0
    public byte[] toByteArray() {
        try {
            int serializedSize = getSerializedSize();
            byte[] bArr = new byte[serializedSize];
            Logger logger = AbstractC1335v.f14361d;
            C1331t c1331t = new C1331t(bArr, 0, serializedSize);
            writeTo(c1331t);
            if (c1331t.b0() == 0) {
                return bArr;
            }
            throw new IllegalStateException("Did not write as much data as expected.");
        } catch (IOException e6) {
            throw new RuntimeException(b("byte array"), e6);
        }
    }

    public AbstractC1320n toByteString() {
        try {
            int serializedSize = getSerializedSize();
            C1318m c1318m = AbstractC1320n.f14310b;
            byte[] bArr = new byte[serializedSize];
            Logger logger = AbstractC1335v.f14361d;
            C1331t c1331t = new C1331t(bArr, 0, serializedSize);
            writeTo(c1331t);
            if (c1331t.b0() == 0) {
                return new C1318m(bArr);
            }
            throw new IllegalStateException("Did not write as much data as expected.");
        } catch (IOException e6) {
            throw new RuntimeException(b("ByteString"), e6);
        }
    }

    public void writeDelimitedTo(OutputStream outputStream) {
        int serializedSize = getSerializedSize();
        int iE = AbstractC1335v.E(serializedSize) + serializedSize;
        if (iE > 4096) {
            iE = 4096;
        }
        C1333u c1333u = new C1333u(outputStream, iE);
        c1333u.Y(serializedSize);
        writeTo(c1333u);
        if (c1333u.f14359h > 0) {
            c1333u.g0();
        }
    }

    @Override // com.google.protobuf.InterfaceC1332t0
    public void writeTo(OutputStream outputStream) {
        int serializedSize = getSerializedSize();
        Logger logger = AbstractC1335v.f14361d;
        if (serializedSize > 4096) {
            serializedSize = 4096;
        }
        C1333u c1333u = new C1333u(outputStream, serializedSize);
        writeTo(c1333u);
        if (c1333u.f14359h > 0) {
            c1333u.g0();
        }
    }

    public static <T> void addAll(Iterable<T> iterable, List<? super T> list) {
        AbstractC1296b.addAll((Iterable) iterable, (List) list);
    }
}
