public class LazyFieldLite
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private ByteString |
delayedBytes
A delayed-parsed version of the contents of this field.
|
private static ExtensionRegistryLite |
EMPTY_REGISTRY |
private ExtensionRegistryLite |
extensionRegistry
An
ExtensionRegistryLite for parsing bytes. |
private ByteString |
memoizedBytes
The memoized bytes for
value . |
protected MessageLite |
value
The parsed value.
|
Constructor and Description |
---|
LazyFieldLite()
Constructs a LazyFieldLite with no contents, and no ability to parse extensions.
|
LazyFieldLite(ExtensionRegistryLite extensionRegistry,
ByteString bytes)
Constructs a LazyFieldLite with bytes that will be parsed lazily.
|
Modifier and Type | Method and Description |
---|---|
private static void |
checkArguments(ExtensionRegistryLite extensionRegistry,
ByteString bytes) |
void |
clear()
Clears the value state of this instance.
|
boolean |
containsDefaultInstance()
Determines whether this LazyFieldLite instance represents the default instance of this type.
|
protected void |
ensureInitialized(MessageLite defaultInstance)
Might lazily parse the bytes that were previously passed in.
|
boolean |
equals(java.lang.Object o) |
static LazyFieldLite |
fromValue(MessageLite value)
Constructs a LazyFieldLite instance with a value.
|
int |
getSerializedSize()
Due to the optional field can be duplicated at the end of serialized
bytes, which will make the serialized size changed after LazyField
parsed.
|
MessageLite |
getValue(MessageLite defaultInstance)
Returns message instance.
|
int |
hashCode() |
void |
merge(LazyFieldLite other)
Merges another instance's contents.
|
void |
mergeFrom(CodedInputStream input,
ExtensionRegistryLite extensionRegistry)
Merges another instance's contents from a stream.
|
private static MessageLite |
mergeValueAndBytes(MessageLite value,
ByteString otherBytes,
ExtensionRegistryLite extensionRegistry) |
void |
set(LazyFieldLite other)
Overrides the contents of this LazyField.
|
void |
setByteString(ByteString bytes,
ExtensionRegistryLite extensionRegistry)
Sets this field with bytes to delay-parse.
|
MessageLite |
setValue(MessageLite value)
Sets the value of the instance and returns the old value without delay parsing anything.
|
ByteString |
toByteString()
Returns a BytesString for this field in a thread-safe way.
|
private static final ExtensionRegistryLite EMPTY_REGISTRY
private ByteString delayedBytes
extensionRegistry
is required to also be non-null.
value
and memoizedBytes
will be initialized lazily.private ExtensionRegistryLite extensionRegistry
ExtensionRegistryLite
for parsing bytes. It is non-null on a best-effort basis. It
is only guaranteed to be non-null if this message was initialized using bytes and an
ExtensionRegistry
. If it directly had a value set then it will be null, unless it has
been merged with another LazyFieldLite
that had an ExtensionRegistry
.protected volatile MessageLite value
delayedBytes
will be parsed lazily at that time.private volatile ByteString memoizedBytes
value
. This is an optimization for the toByteString() method to
not have to recompute its return-value on each invocation.
TODO(yatin): Figure out whether this optimization is actually necessary.public LazyFieldLite(ExtensionRegistryLite extensionRegistry, ByteString bytes)
public LazyFieldLite()
public static LazyFieldLite fromValue(MessageLite value)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean containsDefaultInstance()
public void clear()
LazyField is not thread-safe for write access. Synchronizations are needed under read/write situations.
public void set(LazyFieldLite other)
LazyField is not thread-safe for write access. Synchronizations are needed under read/write situations.
public MessageLite getValue(MessageLite defaultInstance)
defaultInstance
- its message's default instance. It's also used to get parser for the
message type.public MessageLite setValue(MessageLite value)
LazyField is not thread-safe for write access. Synchronizations are needed under read/write situations.
public void merge(LazyFieldLite other)
ExtensionRegistry
but this does not, then this
field will copy over that ExtensionRegistry
.
LazyField is not thread-safe for write access. Synchronizations are needed under read/write situations.
public void mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws java.io.IOException
LazyField is not thread-safe for write access. Synchronizations are needed under read/write situations.
java.io.IOException
private static MessageLite mergeValueAndBytes(MessageLite value, ByteString otherBytes, ExtensionRegistryLite extensionRegistry)
public void setByteString(ByteString bytes, ExtensionRegistryLite extensionRegistry)
public int getSerializedSize()
public ByteString toByteString()
protected void ensureInitialized(MessageLite defaultInstance)
private static void checkArguments(ExtensionRegistryLite extensionRegistry, ByteString bytes)