package com.google.protobuf; import com.google.protobuf.AbstractMessageLite; import com.google.protobuf.AbstractMessageLite.Builder; import com.google.protobuf.ByteString; import com.google.protobuf.MessageLite; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; import java.util.List; /* loaded from: classes3.dex */ public abstract class AbstractMessageLite, BuilderType extends Builder> implements MessageLite { protected int memoizedHashCode = 0; public interface InternalOneOfEnum { int getNumber(); } @Override // com.google.protobuf.MessageLite public ByteString toByteString() { try { ByteString.CodedBuilder newCodedBuilder = ByteString.newCodedBuilder(getSerializedSize()); writeTo(newCodedBuilder.getCodedOutput()); return newCodedBuilder.build(); } catch (IOException e) { throw new RuntimeException(getSerializingExceptionMessage("ByteString"), e); } } @Override // com.google.protobuf.MessageLite public byte[] toByteArray() { try { byte[] bArr = new byte[getSerializedSize()]; CodedOutputStream newInstance = CodedOutputStream.newInstance(bArr); writeTo(newInstance); newInstance.checkNoSpaceLeft(); return bArr; } catch (IOException e) { throw new RuntimeException(getSerializingExceptionMessage("byte array"), e); } } @Override // com.google.protobuf.MessageLite public void writeTo(OutputStream outputStream) throws IOException { CodedOutputStream newInstance = CodedOutputStream.newInstance(outputStream, CodedOutputStream.computePreferredBufferSize(getSerializedSize())); writeTo(newInstance); newInstance.flush(); } @Override // com.google.protobuf.MessageLite public void writeDelimitedTo(OutputStream outputStream) throws IOException { int serializedSize = getSerializedSize(); CodedOutputStream newInstance = CodedOutputStream.newInstance(outputStream, CodedOutputStream.computePreferredBufferSize(CodedOutputStream.computeUInt32SizeNoTag(serializedSize) + serializedSize)); newInstance.writeUInt32NoTag(serializedSize); writeTo(newInstance); newInstance.flush(); } public int getMemoizedSerializedSize() { throw new UnsupportedOperationException(); } public void setMemoizedSerializedSize(int i) { throw new UnsupportedOperationException(); } public int getSerializedSize(Schema schema) { int memoizedSerializedSize = getMemoizedSerializedSize(); if (memoizedSerializedSize != -1) { return memoizedSerializedSize; } int serializedSize = schema.getSerializedSize(this); setMemoizedSerializedSize(serializedSize); return serializedSize; } public UninitializedMessageException newUninitializedMessageException() { return new UninitializedMessageException(this); } private String getSerializingExceptionMessage(String str) { return "Serializing " + getClass().getName() + " to a " + str + " threw an IOException (should never happen)."; } public static void checkByteStringIsUtf8(ByteString byteString) throws IllegalArgumentException { if (!byteString.isValidUtf8()) { throw new IllegalArgumentException("Byte string is not UTF-8."); } } @Deprecated public static void addAll(Iterable iterable, Collection collection) { Builder.addAll((Iterable) iterable, (List) collection); } public static void addAll(Iterable iterable, List list) { Builder.addAll((Iterable) iterable, (List) list); } public static abstract class Builder, BuilderType extends Builder> implements MessageLite.Builder { @Override // /* renamed from: clone */ public abstract BuilderType mo856clone(); public abstract BuilderType internalMergeFrom(MessageType messagetype); @Override // com.google.protobuf.MessageLite.Builder public abstract BuilderType mergeFrom(CodedInputStream codedInputStream, ExtensionRegistryLite extensionRegistryLite) throws IOException; @Override // com.google.protobuf.MessageLite.Builder public BuilderType mergeFrom(CodedInputStream codedInputStream) throws IOException { return mergeFrom(codedInputStream, ExtensionRegistryLite.getEmptyRegistry()); } @Override // com.google.protobuf.MessageLite.Builder public BuilderType mergeFrom(ByteString byteString) throws InvalidProtocolBufferException { try { CodedInputStream newCodedInput = byteString.newCodedInput(); mergeFrom(newCodedInput); newCodedInput.checkLastTagWas(0); return this; } catch (InvalidProtocolBufferException e) { throw e; } catch (IOException e2) { throw new RuntimeException(getReadingExceptionMessage("ByteString"), e2); } } @Override // com.google.protobuf.MessageLite.Builder public BuilderType mergeFrom(ByteString byteString, ExtensionRegistryLite extensionRegistryLite) throws InvalidProtocolBufferException { try { CodedInputStream newCodedInput = byteString.newCodedInput(); mergeFrom(newCodedInput, extensionRegistryLite); newCodedInput.checkLastTagWas(0); return this; } catch (InvalidProtocolBufferException e) { throw e; } catch (IOException e2) { throw new RuntimeException(getReadingExceptionMessage("ByteString"), e2); } } @Override // com.google.protobuf.MessageLite.Builder public BuilderType mergeFrom(byte[] bArr) throws InvalidProtocolBufferException { return mergeFrom(bArr, 0, bArr.length); } @Override // com.google.protobuf.MessageLite.Builder public BuilderType mergeFrom(byte[] bArr, int i, int i2) throws InvalidProtocolBufferException { try { CodedInputStream newInstance = CodedInputStream.newInstance(bArr, i, i2); mergeFrom(newInstance); newInstance.checkLastTagWas(0); return this; } catch (InvalidProtocolBufferException e) { throw e; } catch (IOException e2) { throw new RuntimeException(getReadingExceptionMessage("byte array"), e2); } } @Override // com.google.protobuf.MessageLite.Builder public BuilderType mergeFrom(byte[] bArr, ExtensionRegistryLite extensionRegistryLite) throws InvalidProtocolBufferException { return mergeFrom(bArr, 0, bArr.length, extensionRegistryLite); } @Override // com.google.protobuf.MessageLite.Builder public BuilderType mergeFrom(byte[] bArr, int i, int i2, ExtensionRegistryLite extensionRegistryLite) throws InvalidProtocolBufferException { try { CodedInputStream newInstance = CodedInputStream.newInstance(bArr, i, i2); mergeFrom(newInstance, extensionRegistryLite); newInstance.checkLastTagWas(0); return this; } catch (InvalidProtocolBufferException e) { throw e; } catch (IOException e2) { throw new RuntimeException(getReadingExceptionMessage("byte array"), e2); } } @Override // com.google.protobuf.MessageLite.Builder public BuilderType mergeFrom(InputStream inputStream) throws IOException { CodedInputStream newInstance = CodedInputStream.newInstance(inputStream); mergeFrom(newInstance); newInstance.checkLastTagWas(0); return this; } @Override // com.google.protobuf.MessageLite.Builder public BuilderType mergeFrom(InputStream inputStream, ExtensionRegistryLite extensionRegistryLite) throws IOException { CodedInputStream newInstance = CodedInputStream.newInstance(inputStream); mergeFrom(newInstance, extensionRegistryLite); newInstance.checkLastTagWas(0); return this; } public static final class LimitedInputStream extends FilterInputStream { private int limit; public LimitedInputStream(InputStream inputStream, int i) { super(inputStream); this.limit = i; } @Override // java.io.FilterInputStream, java.io.InputStream public int available() throws IOException { return Math.min(super.available(), this.limit); } @Override // java.io.FilterInputStream, java.io.InputStream public int read() throws IOException { if (this.limit <= 0) { return -1; } int read = super.read(); if (read >= 0) { this.limit--; } return read; } @Override // java.io.FilterInputStream, java.io.InputStream public int read(byte[] bArr, int i, int i2) throws IOException { int i3 = this.limit; if (i3 <= 0) { return -1; } int read = super.read(bArr, i, Math.min(i2, i3)); if (read >= 0) { this.limit -= read; } return read; } @Override // java.io.FilterInputStream, java.io.InputStream public long skip(long j) throws IOException { int skip = (int) super.skip(Math.min(j, this.limit)); if (skip >= 0) { this.limit -= skip; } return skip; } } @Override // com.google.protobuf.MessageLite.Builder public boolean mergeDelimitedFrom(InputStream inputStream, ExtensionRegistryLite extensionRegistryLite) throws IOException { int read = inputStream.read(); if (read == -1) { return false; } mergeFrom((InputStream) new LimitedInputStream(inputStream, CodedInputStream.readRawVarint32(read, inputStream)), extensionRegistryLite); return true; } @Override // com.google.protobuf.MessageLite.Builder public boolean mergeDelimitedFrom(InputStream inputStream) throws IOException { return mergeDelimitedFrom(inputStream, ExtensionRegistryLite.getEmptyRegistry()); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.protobuf.MessageLite.Builder public BuilderType mergeFrom(MessageLite messageLite) { if (!getDefaultInstanceForType().getClass().isInstance(messageLite)) { throw new IllegalArgumentException("mergeFrom(MessageLite) can only merge messages of the same type."); } return (BuilderType) internalMergeFrom((AbstractMessageLite) messageLite); } private String getReadingExceptionMessage(String str) { return "Reading " + getClass().getName() + " from a " + str + " threw an IOException (should never happen)."; } private static void addAllCheckingNulls(Iterable iterable, List list) { if ((list instanceof ArrayList) && (iterable instanceof Collection)) { ((ArrayList) list).ensureCapacity(list.size() + ((Collection) iterable).size()); } int size = list.size(); for (T t : iterable) { if (t == null) { String str = "Element at index " + (list.size() - size) + " is null."; for (int size2 = list.size() - 1; size2 >= size; size2--) { list.remove(size2); } throw new NullPointerException(str); } list.add(t); } } public static UninitializedMessageException newUninitializedMessageException(MessageLite messageLite) { return new UninitializedMessageException(messageLite); } @Deprecated public static void addAll(Iterable iterable, Collection collection) { addAll((Iterable) iterable, (List) collection); } public static void addAll(Iterable iterable, List list) { Internal.checkNotNull(iterable); if (iterable instanceof LazyStringList) { List underlyingElements = ((LazyStringList) iterable).getUnderlyingElements(); LazyStringList lazyStringList = (LazyStringList) list; int size = list.size(); for (Object obj : underlyingElements) { if (obj == null) { String str = "Element at index " + (lazyStringList.size() - size) + " is null."; for (int size2 = lazyStringList.size() - 1; size2 >= size; size2--) { lazyStringList.remove(size2); } throw new NullPointerException(str); } if (obj instanceof ByteString) { lazyStringList.add((ByteString) obj); } else { lazyStringList.add((LazyStringList) obj); } } return; } if (iterable instanceof PrimitiveNonBoxingCollection) { list.addAll((Collection) iterable); } else { addAllCheckingNulls(iterable, list); } } } }