package androidx.datastore.preferences.protobuf;

import com.google.android.gms.measurement.internal.u1;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/* JADX INFO: loaded from: classes.dex */
public abstract class y extends b {
    private static final int MEMOIZED_SERIALIZED_SIZE_MASK = Integer.MAX_VALUE;
    private static final int MUTABLE_FLAG_MASK = Integer.MIN_VALUE;
    static final int UNINITIALIZED_HASH_CODE = 0;
    static final int UNINITIALIZED_SERIALIZED_SIZE = Integer.MAX_VALUE;
    private static Map<Object, y> defaultInstanceMap = new ConcurrentHashMap();
    private int memoizedSerializedSize;
    protected h1 unknownFields;

    public y() {
        this.memoizedHashCode = 0;
        this.memoizedSerializedSize = -1;
        this.unknownFields = h1.f2075f;
    }

    public static y e(Class cls) {
        y yVar = defaultInstanceMap.get(cls);
        if (yVar == null) {
            try {
                Class.forName(cls.getName(), true, cls.getClassLoader());
                yVar = defaultInstanceMap.get(cls);
            } catch (ClassNotFoundException e10) {
                throw new IllegalStateException("Class initialization cannot fail.", e10);
            }
        }
        if (yVar == null) {
            yVar = (y) ((y) n1.d(cls)).d(GeneratedMessageLite$MethodToInvoke.f2012f);
            if (yVar == null) {
                throw new IllegalStateException();
            }
            defaultInstanceMap.put(cls, yVar);
        }
        return yVar;
    }

    public static Object f(Method method, Object obj, Object... objArr) {
        try {
            return method.invoke(obj, objArr);
        } catch (IllegalAccessException e10) {
            throw new RuntimeException("Couldn't use Java reflection to implement protocol message reflection.", e10);
        } catch (InvocationTargetException e11) {
            Throwable cause = e11.getCause();
            if (cause instanceof RuntimeException) {
                throw ((RuntimeException) cause);
            }
            if (cause instanceof Error) {
                throw ((Error) cause);
            }
            throw new RuntimeException("Unexpected exception thrown by generated accessor method.", cause);
        }
    }

    public static final boolean g(y yVar, boolean z10) {
        byte bByteValue = ((Byte) yVar.d(GeneratedMessageLite$MethodToInvoke.f2007a)).byteValue();
        if (bByteValue == 1) {
            return true;
        }
        if (bByteValue == 0) {
            return false;
        }
        v0 v0Var = v0.f2160c;
        v0Var.getClass();
        boolean zC = v0Var.a(yVar.getClass()).c(yVar);
        if (z10) {
            yVar.d(GeneratedMessageLite$MethodToInvoke.f2008b);
        }
        return zC;
    }

    public static void k(Class cls, y yVar) {
        yVar.i();
        defaultInstanceMap.put(cls, yVar);
    }

    @Override // androidx.datastore.preferences.protobuf.b
    public final int a(z0 z0Var) {
        int iE;
        int iE2;
        if (h()) {
            if (z0Var == null) {
                v0 v0Var = v0.f2160c;
                v0Var.getClass();
                iE2 = v0Var.a(getClass()).e(this);
            } else {
                iE2 = z0Var.e(this);
            }
            if (iE2 >= 0) {
                return iE2;
            }
            throw new IllegalStateException(u1.g("serialized size must be non-negative, was ", iE2));
        }
        int i10 = this.memoizedSerializedSize;
        if ((i10 & Integer.MAX_VALUE) != Integer.MAX_VALUE) {
            return i10 & Integer.MAX_VALUE;
        }
        if (z0Var == null) {
            v0 v0Var2 = v0.f2160c;
            v0Var2.getClass();
            iE = v0Var2.a(getClass()).e(this);
        } else {
            iE = z0Var.e(this);
        }
        l(iE);
        return iE;
    }

    public final void b() {
        this.memoizedHashCode = 0;
    }

    public final void c() {
        l(Integer.MAX_VALUE);
    }

    public abstract Object d(GeneratedMessageLite$MethodToInvoke generatedMessageLite$MethodToInvoke);

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        v0 v0Var = v0.f2160c;
        v0Var.getClass();
        return v0Var.a(getClass()).d(this, (y) obj);
    }

    public final boolean h() {
        return (this.memoizedSerializedSize & Integer.MIN_VALUE) != 0;
    }

    public final int hashCode() {
        if (h()) {
            v0 v0Var = v0.f2160c;
            v0Var.getClass();
            return v0Var.a(getClass()).g(this);
        }
        if (this.memoizedHashCode == 0) {
            v0 v0Var2 = v0.f2160c;
            v0Var2.getClass();
            this.memoizedHashCode = v0Var2.a(getClass()).g(this);
        }
        return this.memoizedHashCode;
    }

    public final void i() {
        this.memoizedSerializedSize &= Integer.MAX_VALUE;
    }

    public final y j() {
        return (y) d(GeneratedMessageLite$MethodToInvoke.f2010d);
    }

    public final void l(int i10) {
        if (i10 < 0) {
            throw new IllegalStateException(u1.g("serialized size must be non-negative, was ", i10));
        }
        this.memoizedSerializedSize = (i10 & Integer.MAX_VALUE) | (this.memoizedSerializedSize & Integer.MIN_VALUE);
    }

    public final void m(n nVar) {
        v0 v0Var = v0.f2160c;
        v0Var.getClass();
        z0 z0VarA = v0Var.a(getClass());
        xyz.stream.utils.j0 j0Var = nVar.f2119b;
        if (j0Var == null) {
            j0Var = new xyz.stream.utils.j0(nVar);
        }
        z0VarA.i(this, j0Var);
    }

    public final String toString() {
        String string = super.toString();
        char[] cArr = p0.f2129a;
        StringBuilder sb = new StringBuilder();
        sb.append("# ");
        sb.append(string);
        p0.c(this, sb, 0);
        return sb.toString();
    }
}
