Package akka.protobuf
Class GeneratedMessage.Builder<BuilderType extends GeneratedMessage.Builder>
- java.lang.Object
-
- akka.protobuf.AbstractMessageLite.Builder<BuilderType>
-
- akka.protobuf.AbstractMessage.Builder<BuilderType>
-
- akka.protobuf.GeneratedMessage.Builder<BuilderType>
-
- All Implemented Interfaces:
Message.Builder,MessageLite.Builder,MessageLiteOrBuilder,MessageOrBuilder,java.lang.Cloneable
- Direct Known Subclasses:
DescriptorProtos.DescriptorProto.Builder,DescriptorProtos.DescriptorProto.ExtensionRange.Builder,DescriptorProtos.EnumDescriptorProto.Builder,DescriptorProtos.EnumValueDescriptorProto.Builder,DescriptorProtos.FieldDescriptorProto.Builder,DescriptorProtos.FileDescriptorProto.Builder,DescriptorProtos.FileDescriptorSet.Builder,DescriptorProtos.MethodDescriptorProto.Builder,DescriptorProtos.ServiceDescriptorProto.Builder,DescriptorProtos.SourceCodeInfo.Builder,DescriptorProtos.SourceCodeInfo.Location.Builder,DescriptorProtos.UninterpretedOption.Builder,DescriptorProtos.UninterpretedOption.NamePart.Builder,GeneratedMessage.ExtendableBuilder
- Enclosing class:
- GeneratedMessage
public abstract static class GeneratedMessage.Builder<BuilderType extends GeneratedMessage.Builder> extends AbstractMessage.Builder<BuilderType>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder()protectedBuilder(GeneratedMessage.BuilderParent builderParent)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BuilderTypeaddRepeatedField(Descriptors.FieldDescriptor field, java.lang.Object value)LikesetRepeatedField, but appends the value as a new element.BuilderTypeclear()Called by the initialization and clear code paths to allow subclasses to reset any of their builtin fields back to the initial values.BuilderTypeclearField(Descriptors.FieldDescriptor field)Clears the field.BuilderTypeclone()Clones the Builder.java.util.Map<Descriptors.FieldDescriptor,java.lang.Object>getAllFields()Returns a collection of all the fields in this message which are set and their corresponding values.Descriptors.DescriptorgetDescriptorForType()Get the message's type's descriptor.java.lang.ObjectgetField(Descriptors.FieldDescriptor field)Obtains the value of the given field, or the default value if it is not set.Message.BuildergetFieldBuilder(Descriptors.FieldDescriptor field)Get a nested builder instance for the given field.protected GeneratedMessage.BuilderParentgetParentForChildren()Gets theGeneratedMessage.BuilderParentfor giving to our children.java.lang.ObjectgetRepeatedField(Descriptors.FieldDescriptor field, int index)Gets an element of a repeated field.intgetRepeatedFieldCount(Descriptors.FieldDescriptor field)Gets the number of elements of a repeated field.UnknownFieldSetgetUnknownFields()Get theUnknownFieldSetfor this message.booleanhasField(Descriptors.FieldDescriptor field)Returns true if the given field is set.protected abstract GeneratedMessage.FieldAccessorTableinternalGetFieldAccessorTable()Get the FieldAccessorTable for this type.protected booleanisClean()Gets whether invalidations are neededbooleanisInitialized()Returns true if all required fields in the message and all embedded messages are set, false otherwise.protected voidmarkClean()Called by the subclass or a builder to notify us that a message was built and may be cached and therefore invalidations are needed.BuilderTypemergeUnknownFields(UnknownFieldSet unknownFields)Merge some unknown fields into theUnknownFieldSetfor this message.Message.BuildernewBuilderForField(Descriptors.FieldDescriptor field)Create a Builder for messages of the appropriate type for the given field.protected voidonBuilt()Called by the subclass when a message is built.protected voidonChanged()Called when a the builder or one of its nested children has changed and any parent should be notified of its invalidation.protected booleanparseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)Called by subclasses to parse an unknown field.BuilderTypesetField(Descriptors.FieldDescriptor field, java.lang.Object value)Sets a field to the given value.BuilderTypesetRepeatedField(Descriptors.FieldDescriptor field, int index, java.lang.Object value)Sets an element of a repeated field to the given value.BuilderTypesetUnknownFields(UnknownFieldSet unknownFields)Set theUnknownFieldSetfor this message.-
Methods inherited from class akka.protobuf.AbstractMessage.Builder
findInitializationErrors, getInitializationErrorString, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException
-
Methods inherited from class akka.protobuf.AbstractMessageLite.Builder
addAll, newUninitializedMessageException
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface akka.protobuf.Message.Builder
build, buildPartial
-
Methods inherited from interface akka.protobuf.MessageOrBuilder
getDefaultInstanceForType
-
-
-
-
Constructor Detail
-
Builder
protected Builder()
-
Builder
protected Builder(GeneratedMessage.BuilderParent builderParent)
-
-
Method Detail
-
onBuilt
protected void onBuilt()
Called by the subclass when a message is built.
-
markClean
protected void markClean()
Called by the subclass or a builder to notify us that a message was built and may be cached and therefore invalidations are needed.
-
isClean
protected boolean isClean()
Gets whether invalidations are needed- Returns:
- whether invalidations are needed
-
clone
public BuilderType clone()
Description copied from interface:MessageLite.BuilderClones the Builder.- Specified by:
clonein interfaceMessage.Builder- Specified by:
clonein interfaceMessageLite.Builder- Specified by:
clonein classAbstractMessage.Builder<BuilderType extends GeneratedMessage.Builder>- See Also:
Object.clone()
-
clear
public BuilderType clear()
Called by the initialization and clear code paths to allow subclasses to reset any of their builtin fields back to the initial values.- Specified by:
clearin interfaceMessage.Builder- Specified by:
clearin interfaceMessageLite.Builder- Overrides:
clearin classAbstractMessage.Builder<BuilderType extends GeneratedMessage.Builder>
-
internalGetFieldAccessorTable
protected abstract GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
Get the FieldAccessorTable for this type. We can't have the message class pass this in to the constructor because of bootstrapping trouble with DescriptorProtos.
-
getDescriptorForType
public Descriptors.Descriptor getDescriptorForType()
Description copied from interface:Message.BuilderGet the message's type's descriptor. SeeMessageOrBuilder.getDescriptorForType().
-
getAllFields
public java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> getAllFields()
Description copied from interface:MessageOrBuilderReturns a collection of all the fields in this message which are set and their corresponding values. A singular ("required" or "optional") field is set iff hasField() returns true for that field. A "repeated" field is set iff getRepeatedFieldSize() is greater than zero. The values are exactly what would be returned by callingMessageOrBuilder.getField(Descriptors.FieldDescriptor)for each field. The map is guaranteed to be a sorted map, so iterating over it will return fields in order by field number.
If this is for a builder, the returned map may or may not reflect future changes to the builder. Either way, the returned map is itself unmodifiable.
-
newBuilderForField
public Message.Builder newBuilderForField(Descriptors.FieldDescriptor field)
Description copied from interface:Message.BuilderCreate a Builder for messages of the appropriate type for the given field. Messages built with this can then be passed to setField(), setRepeatedField(), or addRepeatedField().
-
getFieldBuilder
public Message.Builder getFieldBuilder(Descriptors.FieldDescriptor field)
Description copied from interface:Message.BuilderGet a nested builder instance for the given field.Normally, we hold a reference to the immutable message object for the message type field. Some implementations(the generated message builders), however, can also hold a reference to the builder object (a nested builder) for the field.
If the field is already backed up by a nested builder, the nested builder will be returned. Otherwise, a new field builder will be created and returned. The original message field (if exist) will be merged into the field builder, which will then be nested into its parent builder.
NOTE: implementations that do not support nested builders will throw
UnsupportedException.- Specified by:
getFieldBuilderin interfaceMessage.Builder- Overrides:
getFieldBuilderin classAbstractMessage.Builder<BuilderType extends GeneratedMessage.Builder>
-
hasField
public boolean hasField(Descriptors.FieldDescriptor field)
Description copied from interface:MessageOrBuilderReturns true if the given field is set. This is exactly equivalent to calling the generated "has" accessor method corresponding to the field.
-
getField
public java.lang.Object getField(Descriptors.FieldDescriptor field)
Description copied from interface:MessageOrBuilderObtains the value of the given field, or the default value if it is not set. For primitive fields, the boxed primitive value is returned. For enum fields, the EnumValueDescriptor for the value is returned. For embedded message fields, the sub-message is returned. For repeated fields, a java.util.List is returned.
-
setField
public BuilderType setField(Descriptors.FieldDescriptor field, java.lang.Object value)
Description copied from interface:Message.BuilderSets a field to the given value. The value must be of the correct type for this field, i.e. the same type thatMessageOrBuilder.getField(Descriptors.FieldDescriptor)would return.
-
clearField
public BuilderType clearField(Descriptors.FieldDescriptor field)
Description copied from interface:Message.BuilderClears the field. This is exactly equivalent to calling the generated "clear" accessor method corresponding to the field.
-
getRepeatedFieldCount
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Description copied from interface:MessageOrBuilderGets the number of elements of a repeated field. This is exactly equivalent to calling the generated "Count" accessor method corresponding to the field.
-
getRepeatedField
public java.lang.Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
Description copied from interface:MessageOrBuilderGets an element of a repeated field. For primitive fields, the boxed primitive value is returned. For enum fields, the EnumValueDescriptor for the value is returned. For embedded message fields, the sub-message is returned.
-
setRepeatedField
public BuilderType setRepeatedField(Descriptors.FieldDescriptor field, int index, java.lang.Object value)
Description copied from interface:Message.BuilderSets an element of a repeated field to the given value. The value must be of the correct type for this field, i.e. the same type thatMessageOrBuilder.getRepeatedField(Descriptors.FieldDescriptor,int)would return.
-
addRepeatedField
public BuilderType addRepeatedField(Descriptors.FieldDescriptor field, java.lang.Object value)
Description copied from interface:Message.BuilderLikesetRepeatedField, but appends the value as a new element.
-
setUnknownFields
public final BuilderType setUnknownFields(UnknownFieldSet unknownFields)
Description copied from interface:Message.BuilderSet theUnknownFieldSetfor this message.
-
mergeUnknownFields
public final BuilderType mergeUnknownFields(UnknownFieldSet unknownFields)
Description copied from interface:Message.BuilderMerge some unknown fields into theUnknownFieldSetfor this message.- Specified by:
mergeUnknownFieldsin interfaceMessage.Builder- Overrides:
mergeUnknownFieldsin classAbstractMessage.Builder<BuilderType extends GeneratedMessage.Builder>
-
isInitialized
public boolean isInitialized()
Description copied from interface:MessageLiteOrBuilderReturns true if all required fields in the message and all embedded messages are set, false otherwise.
-
getUnknownFields
public final UnknownFieldSet getUnknownFields()
Description copied from interface:MessageOrBuilderGet theUnknownFieldSetfor this message.
-
parseUnknownField
protected boolean parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) throws java.io.IOException
Called by subclasses to parse an unknown field.- Returns:
trueunless the tag is an end-group tag.- Throws:
java.io.IOException
-
getParentForChildren
protected GeneratedMessage.BuilderParent getParentForChildren()
Gets theGeneratedMessage.BuilderParentfor giving to our children.- Returns:
- The builder parent for our children.
-
onChanged
protected final void onChanged()
Called when a the builder or one of its nested children has changed and any parent should be notified of its invalidation.
-
-