package com.google.android.gms.internal.measurement;

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: com.google.android.gms.internal.measurement.a2, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC0609a2 extends M1 {
    private static final Map zzb = new ConcurrentHashMap();
    protected C2 zzc;
    private int zzd;

    public AbstractC0609a2() {
        this.zza = 0;
        this.zzd = -1;
        this.zzc = C2.f9570f;
    }

    public static AbstractC0609a2 g(Class cls) {
        Map map = zzb;
        AbstractC0609a2 abstractC0609a2 = (AbstractC0609a2) map.get(cls);
        if (abstractC0609a2 == null) {
            try {
                Class.forName(cls.getName(), true, cls.getClassLoader());
                abstractC0609a2 = (AbstractC0609a2) map.get(cls);
            } catch (ClassNotFoundException e8) {
                throw new IllegalStateException("Class initialization cannot fail.", e8);
            }
        }
        if (abstractC0609a2 != null) {
            return abstractC0609a2;
        }
        AbstractC0609a2 abstractC0609a22 = (AbstractC0609a2) ((AbstractC0609a2) H2.f(cls)).m(6);
        if (abstractC0609a22 == null) {
            throw new IllegalStateException();
        }
        map.put(cls, abstractC0609a22);
        return abstractC0609a22;
    }

    public static Object h(Method method, M1 m12, Object... objArr) {
        try {
            return method.invoke(m12, 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 void j(Class cls, AbstractC0609a2 abstractC0609a2) {
        abstractC0609a2.i();
        zzb.put(cls, abstractC0609a2);
    }

    @Override // com.google.android.gms.internal.measurement.M1
    public final int a(A2 a22) {
        if (l()) {
            int iC = a22.c(this);
            if (iC >= 0) {
                return iC;
            }
            throw new IllegalStateException(AbstractC0844a.j("serialized size must be non-negative, was ", iC));
        }
        int i = this.zzd & Integer.MAX_VALUE;
        if (i != Integer.MAX_VALUE) {
            return i;
        }
        int iC2 = a22.c(this);
        if (iC2 < 0) {
            throw new IllegalStateException(AbstractC0844a.j("serialized size must be non-negative, was ", iC2));
        }
        this.zzd = (this.zzd & Integer.MIN_VALUE) | iC2;
        return iC2;
    }

    public final int d() {
        if (l()) {
            int iC = C0723x2.f10064c.a(getClass()).c(this);
            if (iC >= 0) {
                return iC;
            }
            throw new IllegalStateException(AbstractC0844a.j("serialized size must be non-negative, was ", iC));
        }
        int i = this.zzd & Integer.MAX_VALUE;
        if (i != Integer.MAX_VALUE) {
            return i;
        }
        int iC2 = C0723x2.f10064c.a(getClass()).c(this);
        if (iC2 < 0) {
            throw new IllegalStateException(AbstractC0844a.j("serialized size must be non-negative, was ", iC2));
        }
        this.zzd = (this.zzd & Integer.MIN_VALUE) | iC2;
        return iC2;
    }

    public final Z1 e() {
        return (Z1) m(5);
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        return C0723x2.f10064c.a(getClass()).f(this, (AbstractC0609a2) obj);
    }

    public final Z1 f() {
        Z1 z12 = (Z1) m(5);
        z12.e(this);
        return z12;
    }

    public final int hashCode() {
        if (l()) {
            return C0723x2.f10064c.a(getClass()).g(this);
        }
        int i = this.zza;
        if (i != 0) {
            return i;
        }
        int iG = C0723x2.f10064c.a(getClass()).g(this);
        this.zza = iG;
        return iG;
    }

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

    public final void k() {
        this.zzd = (this.zzd & Integer.MIN_VALUE) | Integer.MAX_VALUE;
    }

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

    public abstract Object m(int i);

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