package com.google.android.gms.internal.firebase_ml; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.IdentityHashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.TreeSet; import java.util.WeakHashMap; /* loaded from: classes2.dex */ public final class zzhd { private static final Map, zzhd> zzyk = new WeakHashMap(); private static final Map, zzhd> zzyl = new WeakHashMap(); private final Class zzym; private final boolean zzyn; private final IdentityHashMap zzyo = new IdentityHashMap<>(); final List zzyp; public static zzhd zzc(Class cls) { return zza(cls, false); } public static zzhd zza(Class cls, boolean z) { zzhd zzhdVar; if (cls == null) { return null; } Map, zzhd> map = z ? zzyl : zzyk; synchronized (map) { zzhdVar = map.get(cls); if (zzhdVar == null) { zzhdVar = new zzhd(cls, z); map.put(cls, zzhdVar); } } return zzhdVar; } public final zzhl zzao(String str) { if (str != null) { if (this.zzyn) { str = str.toLowerCase(Locale.US); } str = str.intern(); } return this.zzyo.get(str); } public final boolean isEnum() { return this.zzym.isEnum(); } private zzhd(Class cls, boolean z) { this.zzym = cls; this.zzyn = z; boolean z2 = (z && cls.isEnum()) ? false : true; String valueOf = String.valueOf(cls); StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 31); sb.append("cannot ignore case on an enum: "); sb.append(valueOf); zzks.checkArgument(z2, sb.toString()); TreeSet treeSet = new TreeSet(new zzhe(this)); for (Field field : cls.getDeclaredFields()) { zzhl zza = zzhl.zza(field); if (zza != null) { String name = zza.getName(); name = z ? name.toLowerCase(Locale.US).intern() : name; zzhl zzhlVar = this.zzyo.get(name); boolean z3 = zzhlVar == null; Object[] objArr = new Object[4]; objArr[0] = z ? "case-insensitive " : ""; objArr[1] = name; objArr[2] = field; objArr[3] = zzhlVar == null ? null : zzhlVar.zzhf(); if (!z3) { throw new IllegalArgumentException(zzla.zzb("two fields have the same %sname <%s>: %s and %s", objArr)); } this.zzyo.put(name, zza); treeSet.add(name); } } Class superclass = cls.getSuperclass(); if (superclass != null) { zzhd zza2 = zza(superclass, z); treeSet.addAll(zza2.zzyp); for (Map.Entry entry : zza2.zzyo.entrySet()) { String key = entry.getKey(); if (!this.zzyo.containsKey(key)) { this.zzyo.put(key, entry.getValue()); } } } this.zzyp = treeSet.isEmpty() ? Collections.emptyList() : Collections.unmodifiableList(new ArrayList(treeSet)); } public final Collection zzhd() { return Collections.unmodifiableCollection(this.zzyo.values()); } public final boolean zzhc() { return this.zzyn; } }