Package com.google.protobuf
Class GeneratedMessageLite.Builder<MessageType extends GeneratedMessageLite<MessageType,BuilderType>,BuilderType extends GeneratedMessageLite.Builder<MessageType,BuilderType>>
- java.lang.Object
-
- com.google.protobuf.AbstractMessageLite.Builder<MessageType,BuilderType>
-
- com.google.protobuf.GeneratedMessageLite.Builder<MessageType,BuilderType>
-
- All Implemented Interfaces:
MessageLite.Builder
,MessageLiteOrBuilder
,java.lang.Cloneable
- Direct Known Subclasses:
GeneratedMessageLite.ExtendableBuilder
- Enclosing class:
- GeneratedMessageLite<MessageType extends GeneratedMessageLite<MessageType,BuilderType>,BuilderType extends GeneratedMessageLite.Builder<MessageType,BuilderType>>
public abstract static class GeneratedMessageLite.Builder<MessageType extends GeneratedMessageLite<MessageType,BuilderType>,BuilderType extends GeneratedMessageLite.Builder<MessageType,BuilderType>> extends AbstractMessageLite.Builder<MessageType,BuilderType>
-
-
Field Summary
Fields Modifier and Type Field Description protected MessageType
instance
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder(MessageType defaultInstance)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageType
build()
Constructs the message based on the state of the Builder.MessageType
buildPartial()
LikeMessageLite.Builder.build()
, but does not throw an exception if the message is missing required fields.BuilderType
clear()
Resets all fields to their default values.BuilderType
clone()
Clones the Builder.protected void
copyOnWrite()
Called before any method that would mutate the builder to ensure that it correctly copies any state before the write happens to preserve immutability guarantees.protected void
copyOnWriteInternal()
MessageType
getDefaultInstanceForType()
Get an instance of the type with no fields set.protected BuilderType
internalMergeFrom(MessageType message)
boolean
isInitialized()
Returns true if all required fields in the message and all embedded messages are set, false otherwise.BuilderType
mergeFrom(byte[] input, int offset, int length)
Parsedata
as a message of this type and merge it with the message being built.BuilderType
mergeFrom(byte[] input, int offset, int length, ExtensionRegistryLite extensionRegistry)
Parsedata
as a message of this type and merge it with the message being built.BuilderType
mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
LikeMessageLite.Builder.mergeFrom(CodedInputStream)
, but also parses extensions.BuilderType
mergeFrom(MessageType message)
All subclasses implement this.-
Methods inherited from class com.google.protobuf.AbstractMessageLite.Builder
addAll, addAll, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException
-
-
-
-
Field Detail
-
instance
protected MessageType extends GeneratedMessageLite<MessageType,BuilderType> instance
-
-
Constructor Detail
-
Builder
protected Builder(MessageType defaultInstance)
-
-
Method Detail
-
copyOnWrite
protected final void copyOnWrite()
Called before any method that would mutate the builder to ensure that it correctly copies any state before the write happens to preserve immutability guarantees.
-
copyOnWriteInternal
protected void copyOnWriteInternal()
-
isInitialized
public final boolean isInitialized()
Description copied from interface:MessageLiteOrBuilder
Returns true if all required fields in the message and all embedded messages are set, false otherwise.
-
clear
public final BuilderType clear()
Description copied from interface:MessageLite.Builder
Resets all fields to their default values.
-
clone
public BuilderType clone()
Description copied from interface:MessageLite.Builder
Clones the Builder.- Specified by:
clone
in interfaceMessageLite.Builder
- Specified by:
clone
in classAbstractMessageLite.Builder<MessageType extends GeneratedMessageLite<MessageType,BuilderType>,BuilderType extends GeneratedMessageLite.Builder<MessageType,BuilderType>>
- See Also:
Object.clone()
-
buildPartial
public MessageType buildPartial()
Description copied from interface:MessageLite.Builder
LikeMessageLite.Builder.build()
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned. Subsequent changes to the Builder will not affect the returned message.
-
build
public final MessageType build()
Description copied from interface:MessageLite.Builder
Constructs the message based on the state of the Builder. Subsequent changes to the Builder will not affect the returned message.
-
internalMergeFrom
protected BuilderType internalMergeFrom(MessageType message)
- Specified by:
internalMergeFrom
in classAbstractMessageLite.Builder<MessageType extends GeneratedMessageLite<MessageType,BuilderType>,BuilderType extends GeneratedMessageLite.Builder<MessageType,BuilderType>>
-
mergeFrom
public BuilderType mergeFrom(MessageType message)
All subclasses implement this.
-
getDefaultInstanceForType
public MessageType getDefaultInstanceForType()
Description copied from interface:MessageLiteOrBuilder
Get an instance of the type with no fields set. Because no fields are set, all getters for singular fields will return default values and repeated fields will appear empty. This may or may not be a singleton. This differs from thegetDefaultInstance()
method of generated message classes in that this method is an abstract method of theMessageLite
interface whereasgetDefaultInstance()
is a static method of a specific class. They return the same thing.
-
mergeFrom
public BuilderType mergeFrom(byte[] input, int offset, int length, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:MessageLite.Builder
Parsedata
as a message of this type and merge it with the message being built. This is just a small wrapper aroundMessageLite.Builder.mergeFrom(CodedInputStream,ExtensionRegistryLite)
.- Specified by:
mergeFrom
in interfaceMessageLite.Builder
- Overrides:
mergeFrom
in classAbstractMessageLite.Builder<MessageType extends GeneratedMessageLite<MessageType,BuilderType>,BuilderType extends GeneratedMessageLite.Builder<MessageType,BuilderType>>
- Returns:
- this
- Throws:
InvalidProtocolBufferException
- the bytes in data are not syntactically correct according to the protobuf wire format specification. The data is corrupt, incomplete, or was never a protobuf in the first place.
-
mergeFrom
public BuilderType mergeFrom(byte[] input, int offset, int length) throws InvalidProtocolBufferException
Description copied from interface:MessageLite.Builder
Parsedata
as a message of this type and merge it with the message being built. This is just a small wrapper aroundMessageLite.Builder.mergeFrom(CodedInputStream)
.- Specified by:
mergeFrom
in interfaceMessageLite.Builder
- Overrides:
mergeFrom
in classAbstractMessageLite.Builder<MessageType extends GeneratedMessageLite<MessageType,BuilderType>,BuilderType extends GeneratedMessageLite.Builder<MessageType,BuilderType>>
- Returns:
- this
- Throws:
InvalidProtocolBufferException
- the bytes in data are not syntactically correct according to the protobuf wire format specification. The data is corrupt, incomplete, or was never a protobuf in the first place.
-
mergeFrom
public BuilderType mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws java.io.IOException
Description copied from interface:MessageLite.Builder
LikeMessageLite.Builder.mergeFrom(CodedInputStream)
, but also parses extensions. The extensions that you want to be able to parse must be registered inextensionRegistry
. Extensions not in the registry will be treated as unknown fields.- Specified by:
mergeFrom
in interfaceMessageLite.Builder
- Specified by:
mergeFrom
in classAbstractMessageLite.Builder<MessageType extends GeneratedMessageLite<MessageType,BuilderType>,BuilderType extends GeneratedMessageLite.Builder<MessageType,BuilderType>>
- Throws:
InvalidProtocolBufferException
- the bytes read are not syntactically correct according to the protobuf wire format specification. The data is corrupt, incomplete, or was never a protobuf in the first place.java.io.IOException
- an I/O error reading from the stream
-
-