package o; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.IdentityHashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; /* loaded from: classes2.dex */ public final class Coa { private final Class a; final List c; final boolean d; private final IdentityHashMap j = new IdentityHashMap<>(); private static final ConcurrentMap, Coa> e = new ConcurrentHashMap(); private static final ConcurrentMap, Coa> b = new ConcurrentHashMap(); public static Coa a(Class cls) { return c(cls, false); } public static Coa c(Class cls, boolean z) { if (cls == null) { return null; } ConcurrentMap, Coa> concurrentMap = z ? b : e; Coa coa = concurrentMap.get(cls); if (coa != null) { return coa; } Coa coa2 = new Coa(cls, z); Coa putIfAbsent = concurrentMap.putIfAbsent(cls, coa2); return putIfAbsent != null ? putIfAbsent : coa2; } public final NIm c(String str) { if (str != null) { if (this.d) { str = str.toLowerCase(Locale.US); } str = str.intern(); } return this.j.get(str); } private Coa(Class cls, boolean z) { List unmodifiableList; this.a = cls; this.d = z; Preconditions.checkArgument((z && cls.isEnum()) ? false : true, "cannot ignore case on an enum: ".concat(String.valueOf(cls))); TreeSet treeSet = new TreeSet(new Comparator(this) { // from class: o.Coa.3 private Coa c; { this.c = this; } @Override // java.util.Comparator public final /* synthetic */ int compare(String str, String str2) { String str3 = str; String str4 = str2; if (Objects.equal(str3, str4)) { return 0; } if (str3 == null) { return -1; } if (str4 == null) { return 1; } return str3.compareTo(str4); } }); for (Field field : cls.getDeclaredFields()) { NIm b2 = NIm.b(field); if (b2 != null) { String str = b2.b; str = z ? str.toLowerCase(Locale.US).intern() : str; NIm nIm = this.j.get(str); boolean z2 = nIm == null; Object[] objArr = new Object[4]; objArr[0] = z ? "case-insensitive " : ""; objArr[1] = str; objArr[2] = field; objArr[3] = nIm == null ? null : nIm.a; Preconditions.checkArgument(z2, "two fields have the same %sname <%s>: %s and %s", objArr); this.j.put(str, b2); treeSet.add(str); } } Class superclass = cls.getSuperclass(); if (superclass != null) { Coa c = c(superclass, z); treeSet.addAll(c.c); for (Map.Entry entry : c.j.entrySet()) { String key = entry.getKey(); if (!this.j.containsKey(key)) { this.j.put(key, entry.getValue()); } } } if (treeSet.isEmpty()) { unmodifiableList = Collections.emptyList(); } else { unmodifiableList = Collections.unmodifiableList(new ArrayList(treeSet)); } this.c = unmodifiableList; } }