package androidx.datastore.preferences.protobuf;

import d5.AbstractC0844a;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/* JADX INFO: renamed from: androidx.datastore.preferences.protobuf.u, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC0442u extends AbstractC0423a {
    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, AbstractC0442u> defaultInstanceMap = new ConcurrentHashMap();
    private int memoizedSerializedSize;
    protected b0 unknownFields;

    public AbstractC0442u() {
        this.memoizedHashCode = 0;
        this.memoizedSerializedSize = -1;
        this.unknownFields = b0.f8053f;
    }

    public static AbstractC0442u d(Class cls) {
        AbstractC0442u abstractC0442u = defaultInstanceMap.get(cls);
        if (abstractC0442u == null) {
            try {
                Class.forName(cls.getName(), true, cls.getClassLoader());
                abstractC0442u = defaultInstanceMap.get(cls);
            } catch (ClassNotFoundException e8) {
                throw new IllegalStateException("Class initialization cannot fail.", e8);
            }
        }
        if (abstractC0442u != null) {
            return abstractC0442u;
        }
        AbstractC0442u abstractC0442u2 = (AbstractC0442u) ((AbstractC0442u) h0.d(cls)).c(6);
        if (abstractC0442u2 == null) {
            throw new IllegalStateException();
        }
        defaultInstanceMap.put(cls, abstractC0442u2);
        return abstractC0442u2;
    }

    public static Object e(Method method, AbstractC0423a abstractC0423a, Object... objArr) {
        try {
            return method.invoke(abstractC0423a, objArr);
        } catch (IllegalAccessException e8) {
            throw new RuntimeException("Couldn't use Java reflection to implement protocol message reflection.", e8);
        } catch (InvocationTargetException e9) {
            Throwable cause = e9.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 f(AbstractC0442u abstractC0442u, boolean z8) {
        byte bByteValue = ((Byte) abstractC0442u.c(1)).byteValue();
        if (bByteValue == 1) {
            return true;
        }
        if (bByteValue == 0) {
            return false;
        }
        Q q8 = Q.f8024c;
        q8.getClass();
        boolean zA = q8.a(abstractC0442u.getClass()).a(abstractC0442u);
        if (z8) {
            abstractC0442u.c(2);
        }
        return zA;
    }

    public static void j(Class cls, AbstractC0442u abstractC0442u) {
        abstractC0442u.h();
        defaultInstanceMap.put(cls, abstractC0442u);
    }

    @Override // androidx.datastore.preferences.protobuf.AbstractC0423a
    public final int a(U u8) {
        int i;
        int i5;
        if (g()) {
            if (u8 == null) {
                Q q8 = Q.f8024c;
                q8.getClass();
                i5 = q8.a(getClass()).i(this);
            } else {
                i5 = u8.i(this);
            }
            if (i5 >= 0) {
                return i5;
            }
            throw new IllegalStateException(AbstractC0844a.j("serialized size must be non-negative, was ", i5));
        }
        int i8 = this.memoizedSerializedSize;
        if ((i8 & Integer.MAX_VALUE) != Integer.MAX_VALUE) {
            return i8 & Integer.MAX_VALUE;
        }
        if (u8 == null) {
            Q q9 = Q.f8024c;
            q9.getClass();
            i = q9.a(getClass()).i(this);
        } else {
            i = u8.i(this);
        }
        k(i);
        return i;
    }

    @Override // androidx.datastore.preferences.protobuf.AbstractC0423a
    public final void b(C0433k c0433k) {
        Q q8 = Q.f8024c;
        q8.getClass();
        U uA = q8.a(getClass());
        D d8 = c0433k.f8102g;
        if (d8 == null) {
            d8 = new D(c0433k);
        }
        uA.g(this, d8);
    }

    public abstract Object c(int i);

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        Q q8 = Q.f8024c;
        q8.getClass();
        return q8.a(getClass()).e(this, (AbstractC0442u) obj);
    }

    public final boolean g() {
        return (this.memoizedSerializedSize & MUTABLE_FLAG_MASK) != 0;
    }

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

    public final int hashCode() {
        if (g()) {
            Q q8 = Q.f8024c;
            q8.getClass();
            return q8.a(getClass()).h(this);
        }
        if (this.memoizedHashCode == 0) {
            Q q9 = Q.f8024c;
            q9.getClass();
            this.memoizedHashCode = q9.a(getClass()).h(this);
        }
        return this.memoizedHashCode;
    }

    public final AbstractC0442u i() {
        return (AbstractC0442u) c(4);
    }

    public final void k(int i) {
        if (i < 0) {
            throw new IllegalStateException(AbstractC0844a.j("serialized size must be non-negative, was ", i));
        }
        this.memoizedSerializedSize = (i & Integer.MAX_VALUE) | (this.memoizedSerializedSize & MUTABLE_FLAG_MASK);
    }

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