package com.czhj.wire; import com.czhj.wire.Message; import com.czhj.wire.Message.Builder; import com.czhj.wire.WireField; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.List; import java.util.Map; /* access modifiers changed from: package-private */ public final class FieldBinding<M extends Message<M, B>, B extends Message.Builder<M, B>> { private final String a; private final String b; private final Field c; private final Field d; private final Method e; private ProtoAdapter<?> f; private ProtoAdapter<?> g; private ProtoAdapter<Object> h; public final WireField.Label label; public final String name; public final boolean redacted; public final int tag; FieldBinding(WireField wireField, Field field, Class<B> cls) { this.label = wireField.label(); String name2 = field.getName(); this.name = name2; this.tag = wireField.tag(); this.a = wireField.keyAdapter(); this.b = wireField.adapter(); this.redacted = wireField.redacted(); this.c = field; this.d = a((Class<?>) cls, name2); this.e = a(cls, name2, field.getType()); } private static Field a(Class<?> cls, String str) { try { return cls.getField(str); } catch (NoSuchFieldException unused) { throw new AssertionError("No builder field " + cls.getName() + "." + str); } } private static Method a(Class<?> cls, String str, Class<?> cls2) { try { return cls.getMethod(str, cls2); } catch (NoSuchMethodException unused) { throw new AssertionError("No builder method " + cls.getName() + "." + str + "(" + cls2.getName() + ")"); } } /* access modifiers changed from: package-private */ public Object a(B b2) { try { return this.d.get(b2); } catch (IllegalAccessException e2) { throw new AssertionError(e2); } } /* access modifiers changed from: package-private */ public Object a(M m) { try { return this.c.get(m); } catch (IllegalAccessException e2) { throw new AssertionError(e2); } } /* access modifiers changed from: package-private */ public void a(B b2, Object obj) { if (this.label.a()) { ((List) a(b2)).add(obj); } else if (!this.a.isEmpty()) { ((Map) a(b2)).putAll((Map) obj); } else { b(b2, obj); } } /* access modifiers changed from: package-private */ public boolean a() { return !this.a.isEmpty(); } /* access modifiers changed from: package-private */ public ProtoAdapter<?> b() { ProtoAdapter<?> protoAdapter = this.f; if (protoAdapter != null) { return protoAdapter; } ProtoAdapter<?> protoAdapter2 = ProtoAdapter.get(this.b); this.f = protoAdapter2; return protoAdapter2; } /* access modifiers changed from: package-private */ public void b(B b2, Object obj) { try { if (this.label.c()) { this.e.invoke(b2, obj); return; } this.d.set(b2, obj); } catch (Throwable th) { throw new AssertionError(th); } } /* access modifiers changed from: package-private */ public ProtoAdapter<?> c() { ProtoAdapter<?> protoAdapter = this.g; if (protoAdapter != null) { return protoAdapter; } ProtoAdapter<?> protoAdapter2 = ProtoAdapter.get(this.a); this.g = protoAdapter2; return protoAdapter2; } /* access modifiers changed from: package-private */ public ProtoAdapter<Object> d() { ProtoAdapter<Object> protoAdapter = this.h; if (protoAdapter != null) { return protoAdapter; } ProtoAdapter<?> newMapAdapter = a() ? ProtoAdapter.newMapAdapter(c(), b()) : b().withLabel(this.label); this.h = newMapAdapter; return newMapAdapter; } }