Package com.google.protobuf
Class InternalLazyField
- java.lang.Object
-
- com.google.protobuf.InternalLazyField
-
class InternalLazyField extends java.lang.ObjectInternalLazyField 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 Classes Modifier and Type Class Description (package private) static classInternalLazyField.LazyEntry<K>LazyEntry and LazyIterator are used to encapsulate the lazy field, when users iterate all fields from FieldSet.(package private) static classInternalLazyField.LazyIterator<K>
-
Field Summary
Fields Modifier and Type Field Description private ByteStringbytesprivate booleancorruptedprivate MessageLitedefaultInstanceprivate ExtensionRegistryLiteextensionRegistryprotected MessageLitevalue
-
Constructor Summary
Constructors Constructor Description InternalLazyField(MessageLite message)Constructor for InternalLazyField that takes in a message value.InternalLazyField(MessageLite defaultInstance, ExtensionRegistryLite extensionRegistry, ByteString bytes)Constructor for InternalLazyField.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) intcomputeMessageSetExtensionSize(int fieldNumber)(package private) intcomputeSize(int fieldNumber)(package private) intcomputeSizeNoTag()private voidensureInitialized()Guarantees that `this.value` is non-null or throws.booleanequals(java.lang.Object obj)(package private) intgetSerializedSize()(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) ByteStringtoByteString()java.lang.StringtoString()(package private) voidwriteTo(CodedOutputStreamWriter writer, int fieldNumber)
-
-
-
Field Detail
-
defaultInstance
private final MessageLite defaultInstance
-
extensionRegistry
private final ExtensionRegistryLite extensionRegistry
-
bytes
private volatile ByteString bytes
-
value
protected volatile MessageLite value
-
corrupted
private volatile boolean corrupted
-
-
Constructor Detail
-
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 Detail
-
mergeFrom
static InternalLazyField mergeFrom(InternalLazyField lazyField, CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws java.io.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:
java.io.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
static InternalLazyField mergeFrom(InternalLazyField self, InternalLazyField other)
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
private void ensureInitialized() throws InvalidProtocolBufferExceptionGuarantees 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
void writeTo(CodedOutputStreamWriter writer, int fieldNumber) throws java.io.IOException
- Throws:
java.io.IOException
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-