package o; import com.airbnb.deeplinkdispatch.UrlTreeKt; import com.google.android.gms.measurement.api.AppMeasurementSdk; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeSet; import o.KUw; import o.rPU; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class VWe { VWe() { } /* JADX INFO: Access modifiers changed from: package-private */ public static void c(InterfaceC16581pUl interfaceC16581pUl, StringBuilder sb, int i) { HashMap hashMap = new HashMap(); HashMap hashMap2 = new HashMap(); TreeSet treeSet = new TreeSet(); for (Method method : interfaceC16581pUl.getClass().getDeclaredMethods()) { hashMap2.put(method.getName(), method); if (method.getParameterTypes().length == 0) { hashMap.put(method.getName(), method); if (method.getName().startsWith("get")) { treeSet.add(method.getName()); } } } for (String str : treeSet) { String substring = str.startsWith("get") ? str.substring(3) : str; if (substring.endsWith("List") && !substring.endsWith("OrBuilderList") && !substring.equals("List")) { StringBuilder sb2 = new StringBuilder(); sb2.append(substring.substring(0, 1).toLowerCase()); sb2.append(substring.substring(1, substring.length() - 4)); String obj = sb2.toString(); Method method2 = (Method) hashMap.get(str); if (method2 != null && method2.getReturnType().equals(List.class)) { d(sb, i, b(obj), KUw.invokeOrDie(method2, interfaceC16581pUl, new Object[0])); } } if (substring.endsWith("Map") && !substring.equals("Map")) { StringBuilder sb3 = new StringBuilder(); sb3.append(substring.substring(0, 1).toLowerCase()); sb3.append(substring.substring(1, substring.length() - 3)); String obj2 = sb3.toString(); Method method3 = (Method) hashMap.get(str); if (method3 != null && method3.getReturnType().equals(Map.class) && !method3.isAnnotationPresent(Deprecated.class) && Modifier.isPublic(method3.getModifiers())) { d(sb, i, b(obj2), KUw.invokeOrDie(method3, interfaceC16581pUl, new Object[0])); } } if (((Method) hashMap2.get("set".concat(String.valueOf(substring)))) != null) { if (substring.endsWith("Bytes")) { StringBuilder sb4 = new StringBuilder("get"); sb4.append(substring.substring(0, substring.length() - 5)); if (!hashMap.containsKey(sb4.toString())) { } } StringBuilder sb5 = new StringBuilder(); sb5.append(substring.substring(0, 1).toLowerCase()); sb5.append(substring.substring(1)); String obj3 = sb5.toString(); Method method4 = (Method) hashMap.get("get".concat(String.valueOf(substring))); Method method5 = (Method) hashMap.get("has".concat(String.valueOf(substring))); if (method4 != null) { Object invokeOrDie = KUw.invokeOrDie(method4, interfaceC16581pUl, new Object[0]); if (method5 == null) { if (!a(invokeOrDie)) { d(sb, i, b(obj3), invokeOrDie); } } else if (((Boolean) KUw.invokeOrDie(method5, interfaceC16581pUl, new Object[0])).booleanValue()) { d(sb, i, b(obj3), invokeOrDie); } } } } if (interfaceC16581pUl instanceof KUw.Sts) { Iterator> b = ((KUw.Sts) interfaceC16581pUl).extensions.b(); while (b.hasNext()) { Map.Entry next = b.next(); StringBuilder sb6 = new StringBuilder("["); sb6.append(next.getKey().a); sb6.append("]"); d(sb, i, sb6.toString(), next.getValue()); } } KUw kUw = (KUw) interfaceC16581pUl; if (kUw.unknownFields != null) { kUw.unknownFields.a(sb, i); } } private static boolean a(Object obj) { if (obj instanceof Boolean) { return !((Boolean) obj).booleanValue(); } if (obj instanceof Integer) { return ((Integer) obj).intValue() == 0; } if (obj instanceof Float) { return Float.floatToRawIntBits(((Float) obj).floatValue()) == 0; } if (obj instanceof Double) { return Double.doubleToRawLongBits(((Double) obj).doubleValue()) == 0; } if (obj instanceof String) { return obj.equals(""); } if (obj instanceof QwV) { return obj.equals(QwV.a); } return obj instanceof InterfaceC16581pUl ? obj == ((InterfaceC16581pUl) obj).getDefaultInstanceForType() : (obj instanceof Enum) && ((Enum) obj).ordinal() == 0; } /* JADX INFO: Access modifiers changed from: package-private */ public static final void d(StringBuilder sb, int i, String str, Object obj) { if (obj instanceof List) { Iterator it = ((List) obj).iterator(); while (it.hasNext()) { d(sb, i, str, it.next()); } return; } if (obj instanceof Map) { Iterator it2 = ((Map) obj).entrySet().iterator(); while (it2.hasNext()) { d(sb, i, str, (Map.Entry) it2.next()); } return; } sb.append('\n'); int i2 = 0; for (int i3 = 0; i3 < i; i3++) { sb.append(' '); } sb.append(str); if (obj instanceof String) { sb.append(": \""); sb.append(rPU.c(new rPU.AnonymousClass5(QwV.c((String) obj)))); sb.append('\"'); return; } if (obj instanceof QwV) { sb.append(": \""); sb.append(rPU.c(new rPU.AnonymousClass5((QwV) obj))); sb.append('\"'); return; } if (obj instanceof KUw) { sb.append(" {"); c((KUw) obj, sb, i + 2); sb.append("\n"); while (i2 < i) { sb.append(' '); i2++; } sb.append(UrlTreeKt.componentParamSuffix); return; } if (obj instanceof Map.Entry) { sb.append(" {"); Map.Entry entry = (Map.Entry) obj; int i4 = i + 2; d(sb, i4, "key", entry.getKey()); d(sb, i4, AppMeasurementSdk.ConditionalUserProperty.VALUE, entry.getValue()); sb.append("\n"); while (i2 < i) { sb.append(' '); i2++; } sb.append(UrlTreeKt.componentParamSuffix); return; } sb.append(": "); sb.append(obj.toString()); } private static final String b(String str) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < str.length(); i++) { char charAt = str.charAt(i); if (Character.isUpperCase(charAt)) { sb.append("_"); } sb.append(Character.toLowerCase(charAt)); } return sb.toString(); } }