package com.google.protobuf; import com.google.protobuf.MessageLite; import com.google.protobuf.WireFormat; import java.io.IOException; import java.util.AbstractMap; import java.util.Map; /* loaded from: classes3.dex */ public class MapEntryLite { private static final int KEY_FIELD_NUMBER = 1; private static final int VALUE_FIELD_NUMBER = 2; private final K key; private final Metadata metadata; private final V value; public K getKey() { return this.key; } public Metadata getMetadata() { return this.metadata; } public V getValue() { return this.value; } public static class Metadata { public final Object defaultKey; public final Object defaultValue; public final WireFormat.FieldType keyType; public final WireFormat.FieldType valueType; public Metadata(WireFormat.FieldType fieldType, Object obj, WireFormat.FieldType fieldType2, Object obj2) { this.keyType = fieldType; this.defaultKey = obj; this.valueType = fieldType2; this.defaultValue = obj2; } } private MapEntryLite(WireFormat.FieldType fieldType, K k, WireFormat.FieldType fieldType2, V v) { this.metadata = new Metadata(fieldType, k, fieldType2, v); this.key = k; this.value = v; } private MapEntryLite(Metadata metadata, K k, V v) { this.metadata = metadata; this.key = k; this.value = v; } public static MapEntryLite newDefaultInstance(WireFormat.FieldType fieldType, K k, WireFormat.FieldType fieldType2, V v) { return new MapEntryLite<>(fieldType, k, fieldType2, v); } public static void writeTo(CodedOutputStream codedOutputStream, Metadata metadata, K k, V v) throws IOException { FieldSet.writeElement(codedOutputStream, metadata.keyType, 1, k); FieldSet.writeElement(codedOutputStream, metadata.valueType, 2, v); } public static int computeSerializedSize(Metadata metadata, K k, V v) { return FieldSet.computeElementSize(metadata.keyType, 1, k) + FieldSet.computeElementSize(metadata.valueType, 2, v); } /* renamed from: com.google.protobuf.MapEntryLite$1, reason: invalid class name */ public static /* synthetic */ class AnonymousClass1 { static final /* synthetic */ int[] $SwitchMap$com$google$protobuf$WireFormat$FieldType; static { int[] iArr = new int[WireFormat.FieldType.values().length]; $SwitchMap$com$google$protobuf$WireFormat$FieldType = iArr; try { iArr[WireFormat.FieldType.MESSAGE.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { $SwitchMap$com$google$protobuf$WireFormat$FieldType[WireFormat.FieldType.ENUM.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { $SwitchMap$com$google$protobuf$WireFormat$FieldType[WireFormat.FieldType.GROUP.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } } } public static T parseField(CodedInputStream codedInputStream, ExtensionRegistryLite extensionRegistryLite, WireFormat.FieldType fieldType, T t) throws IOException { int i = AnonymousClass1.$SwitchMap$com$google$protobuf$WireFormat$FieldType[fieldType.ordinal()]; if (i == 1) { MessageLite.Builder builder = ((MessageLite) t).toBuilder(); codedInputStream.readMessage(builder, extensionRegistryLite); return (T) builder.buildPartial(); } if (i == 2) { return (T) Integer.valueOf(codedInputStream.readEnum()); } if (i == 3) { throw new RuntimeException("Groups are not allowed in maps."); } return (T) FieldSet.readPrimitiveField(codedInputStream, fieldType, true); } public void serializeTo(CodedOutputStream codedOutputStream, int i, K k, V v) throws IOException { codedOutputStream.writeTag(i, 2); codedOutputStream.writeUInt32NoTag(computeSerializedSize(this.metadata, k, v)); writeTo(codedOutputStream, this.metadata, k, v); } public int computeMessageSize(int i, K k, V v) { return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(computeSerializedSize(this.metadata, k, v)); } public Map.Entry parseEntry(ByteString byteString, ExtensionRegistryLite extensionRegistryLite) throws IOException { return parseEntry(byteString.newCodedInput(), this.metadata, extensionRegistryLite); } public static Map.Entry parseEntry(CodedInputStream codedInputStream, Metadata metadata, ExtensionRegistryLite extensionRegistryLite) throws IOException { Object obj = metadata.defaultKey; Object obj2 = metadata.defaultValue; while (true) { int readTag = codedInputStream.readTag(); if (readTag == 0) { break; } if (readTag == WireFormat.makeTag(1, metadata.keyType.getWireType())) { obj = parseField(codedInputStream, extensionRegistryLite, metadata.keyType, obj); } else if (readTag == WireFormat.makeTag(2, metadata.valueType.getWireType())) { obj2 = parseField(codedInputStream, extensionRegistryLite, metadata.valueType, obj2); } else if (!codedInputStream.skipField(readTag)) { break; } } return new AbstractMap.SimpleImmutableEntry(obj, obj2); } /* JADX WARN: Multi-variable type inference failed */ public void parseInto(MapFieldLite mapFieldLite, CodedInputStream codedInputStream, ExtensionRegistryLite extensionRegistryLite) throws IOException { int pushLimit = codedInputStream.pushLimit(codedInputStream.readRawVarint32()); Metadata metadata = this.metadata; Object obj = metadata.defaultKey; Object obj2 = metadata.defaultValue; while (true) { int readTag = codedInputStream.readTag(); if (readTag == 0) { break; } if (readTag == WireFormat.makeTag(1, this.metadata.keyType.getWireType())) { obj = parseField(codedInputStream, extensionRegistryLite, this.metadata.keyType, obj); } else if (readTag == WireFormat.makeTag(2, this.metadata.valueType.getWireType())) { obj2 = parseField(codedInputStream, extensionRegistryLite, this.metadata.valueType, obj2); } else if (!codedInputStream.skipField(readTag)) { break; } } codedInputStream.checkLastTagWas(0); codedInputStream.popLimit(pushLimit); mapFieldLite.put(obj, obj2); } }