package androidx.datastore.preferences.protobuf; import androidx.core.internal.view.SupportMenu; import androidx.datastore.preferences.protobuf.GeneratedMessageLite; import java.util.Collections; import java.util.HashMap; import java.util.Map; /* loaded from: classes.dex */ public class ExtensionRegistryLite { static final String EXTENSION_CLASS_NAME = "androidx.datastore.preferences.protobuf.Extension"; private static boolean doFullRuntimeInheritanceCheck = true; private static volatile boolean eagerlyParseMessageSets; private static volatile ExtensionRegistryLite emptyRegistry; private final Map> extensionsByNumber; private static final Class extensionClass = resolveExtensionClass(); static final ExtensionRegistryLite EMPTY_REGISTRY_LITE = new ExtensionRegistryLite(true); public static boolean isEagerlyParseMessageSets() { return eagerlyParseMessageSets; } public static void setEagerlyParseMessageSets(boolean z) { eagerlyParseMessageSets = z; } public static Class resolveExtensionClass() { try { return Class.forName(EXTENSION_CLASS_NAME); } catch (ClassNotFoundException unused) { return null; } } public static ExtensionRegistryLite newInstance() { return doFullRuntimeInheritanceCheck ? ExtensionRegistryFactory.create() : new ExtensionRegistryLite(); } public static ExtensionRegistryLite getEmptyRegistry() { ExtensionRegistryLite extensionRegistryLite = emptyRegistry; if (extensionRegistryLite == null) { synchronized (ExtensionRegistryLite.class) { try { extensionRegistryLite = emptyRegistry; if (extensionRegistryLite == null) { extensionRegistryLite = doFullRuntimeInheritanceCheck ? ExtensionRegistryFactory.createEmpty() : EMPTY_REGISTRY_LITE; emptyRegistry = extensionRegistryLite; } } finally { } } } return extensionRegistryLite; } public ExtensionRegistryLite getUnmodifiable() { return new ExtensionRegistryLite(this); } public GeneratedMessageLite.GeneratedExtension findLiteExtensionByNumber(ContainingType containingtype, int i) { return (GeneratedMessageLite.GeneratedExtension) this.extensionsByNumber.get(new ObjectIntPair(containingtype, i)); } public final void add(GeneratedMessageLite.GeneratedExtension generatedExtension) { this.extensionsByNumber.put(new ObjectIntPair(generatedExtension.getContainingTypeDefaultInstance(), generatedExtension.getNumber()), generatedExtension); } public final void add(ExtensionLite extensionLite) { if (GeneratedMessageLite.GeneratedExtension.class.isAssignableFrom(extensionLite.getClass())) { add((GeneratedMessageLite.GeneratedExtension) extensionLite); } if (doFullRuntimeInheritanceCheck && ExtensionRegistryFactory.isFullRegistry(this)) { try { getClass().getMethod("add", extensionClass).invoke(this, extensionLite); } catch (Exception e) { throw new IllegalArgumentException(String.format("Could not invoke ExtensionRegistry#add for %s", extensionLite), e); } } } public ExtensionRegistryLite() { this.extensionsByNumber = new HashMap(); } public ExtensionRegistryLite(ExtensionRegistryLite extensionRegistryLite) { if (extensionRegistryLite == EMPTY_REGISTRY_LITE) { this.extensionsByNumber = Collections.emptyMap(); } else { this.extensionsByNumber = Collections.unmodifiableMap(extensionRegistryLite.extensionsByNumber); } } public ExtensionRegistryLite(boolean z) { this.extensionsByNumber = Collections.emptyMap(); } public static final class ObjectIntPair { private final int number; private final Object object; public ObjectIntPair(Object obj, int i) { this.object = obj; this.number = i; } public int hashCode() { return (System.identityHashCode(this.object) * SupportMenu.USER_MASK) + this.number; } public boolean equals(Object obj) { if (!(obj instanceof ObjectIntPair)) { return false; } ObjectIntPair objectIntPair = (ObjectIntPair) obj; return this.object == objectIntPair.object && this.number == objectIntPair.number; } } }