what-the-bank/sources/com/google/android/gms/internal/firebase_ml/zzhl.java

144 lines
4.6 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.internal.firebase_ml;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.WeakHashMap;
/* loaded from: classes2.dex */
public final class zzhl {
private static final Map<Field, zzhl> zzyk = new WeakHashMap();
private final String name;
private final boolean zzzp;
private final Field zzzq;
public static zzhl zza(Enum<?> r2) {
try {
zzhl zza = zza(r2.getClass().getField(r2.name()));
Object[] objArr = {r2};
if (zza != null) {
return zza;
}
throw new IllegalArgumentException(zzla.zzb("enum constant missing @Value or @NullValue annotation: %s", objArr));
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
}
public static zzhl zza(Field field) {
String str = null;
if (field == null) {
return null;
}
Map<Field, zzhl> map = zzyk;
synchronized (map) {
zzhl zzhlVar = map.get(field);
boolean isEnumConstant = field.isEnumConstant();
if (zzhlVar == null && (isEnumConstant || !Modifier.isStatic(field.getModifiers()))) {
if (isEnumConstant) {
zzid zzidVar = (zzid) field.getAnnotation(zzid.class);
if (zzidVar != null) {
str = zzidVar.value();
} else if (((zzht) field.getAnnotation(zzht.class)) == null) {
return null;
}
} else {
zzho zzhoVar = (zzho) field.getAnnotation(zzho.class);
if (zzhoVar == null) {
return null;
}
str = zzhoVar.value();
field.setAccessible(true);
}
if ("##default".equals(str)) {
str = field.getName();
}
zzhlVar = new zzhl(field, str);
map.put(field, zzhlVar);
}
return zzhlVar;
}
}
private zzhl(Field field, String str) {
this.zzzq = field;
this.name = str == null ? null : str.intern();
this.zzzp = zzhf.zza(field.getType());
}
public final Type getGenericType() {
return this.zzzq.getGenericType();
}
public final boolean zzhg() {
return Modifier.isFinal(this.zzzq.getModifiers());
}
public final Object zzh(Object obj) {
return zza(this.zzzq, obj);
}
public final void zzb(Object obj, Object obj2) {
zza(this.zzzq, obj, obj2);
}
public final <T extends Enum<T>> T zzhh() {
return (T) Enum.valueOf(this.zzzq.getDeclaringClass(), this.zzzq.getName());
}
private static Object zza(Field field, Object obj) {
try {
return field.get(obj);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(e);
}
}
public static void zza(Field field, Object obj, Object obj2) {
if (Modifier.isFinal(field.getModifiers())) {
Object zza = zza(field, obj);
if (obj2 == null) {
if (zza == null) {
return;
}
} else if (obj2.equals(zza)) {
return;
}
String valueOf = String.valueOf(zza);
String valueOf2 = String.valueOf(obj2);
String name = field.getName();
String name2 = obj.getClass().getName();
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 48 + String.valueOf(valueOf2).length() + String.valueOf(name).length() + String.valueOf(name2).length());
sb.append("expected final value <");
sb.append(valueOf);
sb.append("> but was <");
sb.append(valueOf2);
sb.append("> on ");
sb.append(name);
sb.append(" field in ");
sb.append(name2);
throw new IllegalArgumentException(sb.toString());
}
try {
field.set(obj, obj2);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(e);
} catch (SecurityException e2) {
throw new IllegalArgumentException(e2);
}
}
public final Field zzhf() {
return this.zzzq;
}
public final boolean isPrimitive() {
return this.zzzp;
}
public final String getName() {
return this.name;
}
}