Class InternalLazyField
java.lang.Object
com.google.protobuf.InternalLazyField
InternalLazyField encapsulates the logic of lazily parsing message fields. It stores the message
in a ByteString initially and then parses it on-demand.
The invariants of InternalLazyField are that 1) once value or bytes is set, they will not be changed; 2) value and bytes cannot be null at the same time; 3) If corrupted is true, value must be null.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classLazyEntry and LazyIterator are used to encapsulate the lazy field, when users iterate all fields from FieldSet.(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ByteStringprivate booleanprivate final MessageLiteprivate final ExtensionRegistryLiteprotected MessageLite -
Constructor Summary
ConstructorsConstructorDescriptionInternalLazyField(MessageLite message) Constructor for InternalLazyField that takes in a message value.InternalLazyField(MessageLite defaultInstance, ExtensionRegistryLite extensionRegistry, ByteString bytes) Constructor for InternalLazyField. -
Method Summary
Modifier and TypeMethodDescription(package private) intcomputeMessageSetExtensionSize(int fieldNumber) (package private) intcomputeSize(int fieldNumber) (package private) intprivate voidGuarantees that `this.value` is non-null or throws.boolean(package private) int(package private) MessageLitegetValue()Returns the parsed message value.private booleanhasBytes()inthashCode()private booleanisEmpty()(package private) static InternalLazyFieldmergeFrom(InternalLazyField lazyField, CodedInputStream input, ExtensionRegistryLite extensionRegistry) Merges the InternalLazyField from the given CodedInputStream with the given extension registry.(package private) static InternalLazyFieldmergeFrom(InternalLazyField self, InternalLazyField other) Merges a InternalLazyField from another InternalLazyField.(package private) ByteStringtoString()(package private) voidwriteTo(CodedOutputStreamWriter writer, int fieldNumber)
-
Field Details
-
defaultInstance
-
extensionRegistry
-
bytes
-
value
-
corrupted
private volatile boolean corrupted
-
-
Constructor Details
-
InternalLazyField
InternalLazyField(MessageLite defaultInstance, ExtensionRegistryLite extensionRegistry, ByteString bytes) Constructor for InternalLazyField. All arguments cannot be null. -
InternalLazyField
InternalLazyField(MessageLite message) Constructor for InternalLazyField that takes in a message value. The argument cannot be null.
-
-
Method Details
-
mergeFrom
static InternalLazyField mergeFrom(InternalLazyField lazyField, CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws IOException Merges the InternalLazyField from the given CodedInputStream with the given extension registry.Precondition: the input stream should have already read the tag and be expected to read the size of the bytes next.
- Throws:
IOException- only if an error occurs while reading the raw bytes from the input stream, not for failures in parsing the read bytes.InvalidProtobufRuntimeException- if the lazy field is corrupted and cannot be merged with a different extension registry.
-
mergeFrom
Merges a InternalLazyField from another InternalLazyField.- Throws:
InvalidProtobufRuntimeException- if either lazy field is corrupted and cannot be merged with a different extension registry.
-
hasBytes
private boolean hasBytes() -
isEmpty
private boolean isEmpty() -
ensureInitialized
Guarantees that `this.value` is non-null or throws.- Throws:
InvalidProtocolBufferException- If `bytes` cannot be parsed.
-
getValue
MessageLite getValue()Returns the parsed message value.If the lazy field is corrupted, it will throw a runtime exception if
ExtensionRegistryLite.lazyExtensionEnabled()is true, otherwise it will return the default instance. -
getSerializedSize
int getSerializedSize() -
toByteString
ByteString toByteString() -
computeSizeNoTag
int computeSizeNoTag() -
computeSize
int computeSize(int fieldNumber) -
computeMessageSetExtensionSize
int computeMessageSetExtensionSize(int fieldNumber) -
writeTo
- Throws:
IOException
-
hashCode
-
equals
-
toString
-