package androidx.datastore.preferences.protobuf; import androidx.datastore.preferences.protobuf.Writer; import com.ironsource.mediationsdk.logger.IronSourceError; import java.io.IOException; import java.util.Arrays; /* loaded from: classes.dex */ public final class UnknownFieldSetLite { private static final UnknownFieldSetLite DEFAULT_INSTANCE = new UnknownFieldSetLite(0, new int[0], new Object[0], false); private static final int MIN_CAPACITY = 8; private int count; private boolean isMutable; private int memoizedSerializedSize; private Object[] objects; private int[] tags; public static UnknownFieldSetLite getDefaultInstance() { return DEFAULT_INSTANCE; } public void makeImmutable() { this.isMutable = false; } public static UnknownFieldSetLite newInstance() { return new UnknownFieldSetLite(); } public static UnknownFieldSetLite mutableCopyOf(UnknownFieldSetLite unknownFieldSetLite, UnknownFieldSetLite unknownFieldSetLite2) { int i = unknownFieldSetLite.count + unknownFieldSetLite2.count; int[] copyOf = Arrays.copyOf(unknownFieldSetLite.tags, i); System.arraycopy(unknownFieldSetLite2.tags, 0, copyOf, unknownFieldSetLite.count, unknownFieldSetLite2.count); Object[] copyOf2 = Arrays.copyOf(unknownFieldSetLite.objects, i); System.arraycopy(unknownFieldSetLite2.objects, 0, copyOf2, unknownFieldSetLite.count, unknownFieldSetLite2.count); return new UnknownFieldSetLite(i, copyOf, copyOf2, true); } private UnknownFieldSetLite() { this(0, new int[8], new Object[8], true); } private UnknownFieldSetLite(int i, int[] iArr, Object[] objArr, boolean z) { this.memoizedSerializedSize = -1; this.count = i; this.tags = iArr; this.objects = objArr; this.isMutable = z; } public void checkMutable() { if (!this.isMutable) { throw new UnsupportedOperationException(); } } public void writeTo(CodedOutputStream codedOutputStream) throws IOException { for (int i = 0; i < this.count; i++) { int i2 = this.tags[i]; int tagFieldNumber = WireFormat.getTagFieldNumber(i2); int tagWireType = WireFormat.getTagWireType(i2); if (tagWireType == 0) { codedOutputStream.writeUInt64(tagFieldNumber, ((Long) this.objects[i]).longValue()); } else if (tagWireType == 1) { codedOutputStream.writeFixed64(tagFieldNumber, ((Long) this.objects[i]).longValue()); } else if (tagWireType == 2) { codedOutputStream.writeBytes(tagFieldNumber, (ByteString) this.objects[i]); } else if (tagWireType == 3) { codedOutputStream.writeTag(tagFieldNumber, 3); ((UnknownFieldSetLite) this.objects[i]).writeTo(codedOutputStream); codedOutputStream.writeTag(tagFieldNumber, 4); } else if (tagWireType == 5) { codedOutputStream.writeFixed32(tagFieldNumber, ((Integer) this.objects[i]).intValue()); } else { throw InvalidProtocolBufferException.invalidWireType(); } } } public void writeAsMessageSetTo(CodedOutputStream codedOutputStream) throws IOException { for (int i = 0; i < this.count; i++) { codedOutputStream.writeRawMessageSetExtension(WireFormat.getTagFieldNumber(this.tags[i]), (ByteString) this.objects[i]); } } public void writeAsMessageSetTo(Writer writer) throws IOException { if (writer.fieldOrder() == Writer.FieldOrder.DESCENDING) { for (int i = this.count - 1; i >= 0; i--) { writer.writeMessageSetItem(WireFormat.getTagFieldNumber(this.tags[i]), this.objects[i]); } return; } for (int i2 = 0; i2 < this.count; i2++) { writer.writeMessageSetItem(WireFormat.getTagFieldNumber(this.tags[i2]), this.objects[i2]); } } public void writeTo(Writer writer) throws IOException { if (this.count == 0) { return; } if (writer.fieldOrder() == Writer.FieldOrder.ASCENDING) { for (int i = 0; i < this.count; i++) { writeField(this.tags[i], this.objects[i], writer); } return; } for (int i2 = this.count - 1; i2 >= 0; i2--) { writeField(this.tags[i2], this.objects[i2], writer); } } private static void writeField(int i, Object obj, Writer writer) throws IOException { int tagFieldNumber = WireFormat.getTagFieldNumber(i); int tagWireType = WireFormat.getTagWireType(i); if (tagWireType == 0) { writer.writeInt64(tagFieldNumber, ((Long) obj).longValue()); return; } if (tagWireType == 1) { writer.writeFixed64(tagFieldNumber, ((Long) obj).longValue()); return; } if (tagWireType == 2) { writer.writeBytes(tagFieldNumber, (ByteString) obj); return; } if (tagWireType != 3) { if (tagWireType == 5) { writer.writeFixed32(tagFieldNumber, ((Integer) obj).intValue()); return; } throw new RuntimeException(InvalidProtocolBufferException.invalidWireType()); } if (writer.fieldOrder() == Writer.FieldOrder.ASCENDING) { writer.writeStartGroup(tagFieldNumber); ((UnknownFieldSetLite) obj).writeTo(writer); writer.writeEndGroup(tagFieldNumber); } else { writer.writeEndGroup(tagFieldNumber); ((UnknownFieldSetLite) obj).writeTo(writer); writer.writeStartGroup(tagFieldNumber); } } public int getSerializedSizeAsMessageSet() { int i = this.memoizedSerializedSize; if (i != -1) { return i; } int i2 = 0; for (int i3 = 0; i3 < this.count; i3++) { i2 += CodedOutputStream.computeRawMessageSetExtensionSize(WireFormat.getTagFieldNumber(this.tags[i3]), (ByteString) this.objects[i3]); } this.memoizedSerializedSize = i2; return i2; } public int getSerializedSize() { int computeUInt64Size; int i = this.memoizedSerializedSize; if (i != -1) { return i; } int i2 = 0; for (int i3 = 0; i3 < this.count; i3++) { int i4 = this.tags[i3]; int tagFieldNumber = WireFormat.getTagFieldNumber(i4); int tagWireType = WireFormat.getTagWireType(i4); if (tagWireType == 0) { computeUInt64Size = CodedOutputStream.computeUInt64Size(tagFieldNumber, ((Long) this.objects[i3]).longValue()); } else if (tagWireType == 1) { computeUInt64Size = CodedOutputStream.computeFixed64Size(tagFieldNumber, ((Long) this.objects[i3]).longValue()); } else if (tagWireType == 2) { computeUInt64Size = CodedOutputStream.computeBytesSize(tagFieldNumber, (ByteString) this.objects[i3]); } else if (tagWireType == 3) { computeUInt64Size = (CodedOutputStream.computeTagSize(tagFieldNumber) * 2) + ((UnknownFieldSetLite) this.objects[i3]).getSerializedSize(); } else if (tagWireType == 5) { computeUInt64Size = CodedOutputStream.computeFixed32Size(tagFieldNumber, ((Integer) this.objects[i3]).intValue()); } else { throw new IllegalStateException(InvalidProtocolBufferException.invalidWireType()); } i2 += computeUInt64Size; } this.memoizedSerializedSize = i2; return i2; } private static boolean equals(int[] iArr, int[] iArr2, int i) { for (int i2 = 0; i2 < i; i2++) { if (iArr[i2] != iArr2[i2]) { return false; } } return true; } private static boolean equals(Object[] objArr, Object[] objArr2, int i) { for (int i2 = 0; i2 < i; i2++) { if (!objArr[i2].equals(objArr2[i2])) { return false; } } return true; } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || !(obj instanceof UnknownFieldSetLite)) { return false; } UnknownFieldSetLite unknownFieldSetLite = (UnknownFieldSetLite) obj; int i = this.count; return i == unknownFieldSetLite.count && equals(this.tags, unknownFieldSetLite.tags, i) && equals(this.objects, unknownFieldSetLite.objects, this.count); } private static int hashCode(int[] iArr, int i) { int i2 = 17; for (int i3 = 0; i3 < i; i3++) { i2 = (i2 * 31) + iArr[i3]; } return i2; } private static int hashCode(Object[] objArr, int i) { int i2 = 17; for (int i3 = 0; i3 < i; i3++) { i2 = (i2 * 31) + objArr[i3].hashCode(); } return i2; } public int hashCode() { int i = this.count; return ((((IronSourceError.ERROR_NON_EXISTENT_INSTANCE + i) * 31) + hashCode(this.tags, i)) * 31) + hashCode(this.objects, this.count); } public final void printWithIndent(StringBuilder sb, int i) { for (int i2 = 0; i2 < this.count; i2++) { MessageLiteToString.printField(sb, i, String.valueOf(WireFormat.getTagFieldNumber(this.tags[i2])), this.objects[i2]); } } public void storeField(int i, Object obj) { checkMutable(); ensureCapacity(); int[] iArr = this.tags; int i2 = this.count; iArr[i2] = i; this.objects[i2] = obj; this.count = i2 + 1; } private void ensureCapacity() { int i = this.count; int[] iArr = this.tags; if (i == iArr.length) { int i2 = i + (i < 4 ? 8 : i >> 1); this.tags = Arrays.copyOf(iArr, i2); this.objects = Arrays.copyOf(this.objects, i2); } } public boolean mergeFieldFrom(int i, CodedInputStream codedInputStream) throws IOException { checkMutable(); int tagFieldNumber = WireFormat.getTagFieldNumber(i); int tagWireType = WireFormat.getTagWireType(i); if (tagWireType == 0) { storeField(i, Long.valueOf(codedInputStream.readInt64())); return true; } if (tagWireType == 1) { storeField(i, Long.valueOf(codedInputStream.readFixed64())); return true; } if (tagWireType == 2) { storeField(i, codedInputStream.readBytes()); return true; } if (tagWireType == 3) { UnknownFieldSetLite unknownFieldSetLite = new UnknownFieldSetLite(); unknownFieldSetLite.mergeFrom(codedInputStream); codedInputStream.checkLastTagWas(WireFormat.makeTag(tagFieldNumber, 4)); storeField(i, unknownFieldSetLite); return true; } if (tagWireType == 4) { return false; } if (tagWireType == 5) { storeField(i, Integer.valueOf(codedInputStream.readFixed32())); return true; } throw InvalidProtocolBufferException.invalidWireType(); } public UnknownFieldSetLite mergeVarintField(int i, int i2) { checkMutable(); if (i == 0) { throw new IllegalArgumentException("Zero is not a valid field number."); } storeField(WireFormat.makeTag(i, 0), Long.valueOf(i2)); return this; } public UnknownFieldSetLite mergeLengthDelimitedField(int i, ByteString byteString) { checkMutable(); if (i == 0) { throw new IllegalArgumentException("Zero is not a valid field number."); } storeField(WireFormat.makeTag(i, 2), byteString); return this; } private UnknownFieldSetLite mergeFrom(CodedInputStream codedInputStream) throws IOException { int readTag; do { readTag = codedInputStream.readTag(); if (readTag == 0) { break; } } while (mergeFieldFrom(readTag, codedInputStream)); return this; } }