Package com.google.protobuf

# Class GeneratedMessage.ExtendableMessage<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>

java.lang.Object
com.google.protobuf.AbstractMessageLite
com.google.protobuf.AbstractMessage
com.google.protobuf.GeneratedMessage
com.google.protobuf.GeneratedMessage.ExtendableMessage<MessageT>

All Implemented Interfaces:
  `GeneratedMessage.ExtendableMessageOrBuilder<MessageT>`, `Message`, `MessageLite`, `MessageLiteOrBuilder`, `MessageOrBuilder`, `Serializable`

Direct Known Subclasses:
  `DescriptorProtos.EnumOptions`, `DescriptorProtos.EnumValueOptions`, `DescriptorProtos.ExtensionRangeOptions`, `DescriptorProtos.FeatureSet`, `DescriptorProtos.FieldOptions`, `DescriptorProtos.FileDescriptorSet`, `DescriptorProtos.FileOptions`, `DescriptorProtos.MessageOptions`, `DescriptorProtos.MethodOptions`, `DescriptorProtos.OneofOptions`, `DescriptorProtos.ServiceOptions`, `DescriptorProtos.SourceCodeInfo`, `GeneratedMessageV3`

Enclosing class:
  `GeneratedMessage`

public abstract static class GeneratedMessage.ExtendableMessage<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>> extends GeneratedMessage implements GeneratedMessage.ExtendableMessageOrBuilder<MessageT>
Generated message classes for message types that contain extension ranges subclass this.

This class implements type-safe accessors for extensions. They implement all the same operations that you can do with normal fields -- e.g. "has", "get", and "getCount" -- but for extensions. The extensions are identified using instances of the class `GeneratedMessage.GeneratedExtension`; the protocol compiler generates a static instance of this class for every extension in its input. Through the magic of generics, all is made type-safe.

For example, imagine you have the `.proto` file:

     option java_class = "MyProto";

     message Foo {
       extensions 1000 to max;
     }

     extend Foo {
       optional int32 bar;
     }

Then you might write code like:

     MyProto.Foo foo = getFoo();
     int i = foo.getExtension(MyProto.bar);

See also `GeneratedMessage.ExtendableBuilder`.

See Also:
  - Serialized Form

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected static interface`
`GeneratedMessage.ExtendableMessage.ExtensionSerializer`
Used by subclasses to serialize extensions.
`protected class`
`GeneratedMessage.ExtendableMessage.ExtensionWriter`
ExtensionSerializer that writes extensions from the FieldSet, for messages with extensions.

## Nested classes/interfaces inherited from class com.google.protobuf.GeneratedMessage

`GeneratedMessage.Builder<BuilderT extends GeneratedMessage.Builder<BuilderT>>, GeneratedMessage.ExtendableBuilder<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>,BuilderT extends GeneratedMessage.ExtendableBuilder<MessageT,BuilderT>>, GeneratedMessage.ExtendableMessage<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>, GeneratedMessage.ExtendableMessageOrBuilder<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>, GeneratedMessage.FieldAccessorTable, GeneratedMessage.GeneratedExtension<ContainingT extends Message,T>, GeneratedMessage.UnusedPrivateParameter`

## Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessage

`AbstractMessage.BuilderParent`

## Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite

`AbstractMessageLite.InternalOneOfEnum`

## Field Summary

### Fields inherited from class com.google.protobuf.GeneratedMessage

`alwaysUseFieldBuilders, unknownFields`

### Fields inherited from class com.google.protobuf.AbstractMessage

`memoizedSize`

### Fields inherited from class com.google.protobuf.AbstractMessageLite

`memoizedHashCode`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`ExtendableMessage()`
`protected`
`ExtendableMessage(GeneratedMessage.ExtendableBuilder<MessageT,?> builder)`

## Method Summary

Modifier and Type
Method
Description
`protected boolean`
`extensionsAreInitialized()`
Called by subclasses to check if all extensions are initialized.
`protected int`
`extensionsSerializedSize()`
Called by subclasses to compute the size of extensions.
`protected int`
`extensionsSerializedSizeAsMessageSet()`
`Map<Descriptors.FieldDescriptor,Object>`
`getAllFields()`
Returns a collection of all the fields in this message which are set and their corresponding values.
`Map<Descriptors.FieldDescriptor,Object>`
`getAllFieldsRaw()`
`final <T> T`
`getExtension(ExtensionLite<? extends MessageT,List<T>> extensionLite, int index)`
Get one element of a repeated extension.
`final <T> T`
`getExtension(ExtensionLite<? extends MessageT,T> extensionLite)`
Get the value of an extension.
`final <T> int`
`getExtensionCount(ExtensionLite<? extends MessageT,List<T>> extensionLite)`
Get the number of elements in a repeated extension.
`protected Map<Descriptors.FieldDescriptor,Object>`
`getExtensionFields()`
`Object`
`getField(Descriptors.FieldDescriptor field)`
Obtains the value of the given field, or the default value if it is not set.
`Object`
`getRepeatedField(Descriptors.FieldDescriptor field, int index)`
Gets an element of a repeated field.
`int`
`getRepeatedFieldCount(Descriptors.FieldDescriptor field)`
Gets the number of elements of a repeated field.
`final <T> boolean`
`hasExtension(ExtensionLite<? extends MessageT,T> extensionLite)`
Check if a singular extension is present.
`boolean`
`hasField(Descriptors.FieldDescriptor field)`
Returns true if the given field is set.
`boolean`
`isInitialized()`
Returns true if all required fields in the message and all embedded messages are set, false otherwise.
`protected GeneratedMessage.ExtendableMessage.ExtensionSerializer`
`newExtensionSerializer()`
`protected GeneratedMessage.ExtendableMessage<MessageT>.ExtensionWriter`
`newExtensionWriter()`
Deprecated.
Use `newExtensionSerializer()` instead.
`protected GeneratedMessage.ExtendableMessage.ExtensionSerializer`
`newMessageSetExtensionSerializer()`
`protected GeneratedMessage.ExtendableMessage<MessageT>.ExtensionWriter`
`newMessageSetExtensionWriter()`

### Methods inherited from class com.google.protobuf.GeneratedMessage

`canUseUnsafe, computeStringSize, computeStringSizeNoTag, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyList, emptyLongList, getDescriptorForType, getOneofFieldDescriptor, getParserForType, getSerializedSize, getUnknownFields, hasOneof, internalGetFieldAccessorTable, internalGetMapField, internalGetMapFieldReflection, isStringEmpty, makeMutableCopy, makeMutableCopy, mergeFromAndMakeImmutableInternal, newFileScopedGeneratedExtension, newInstance, newMessageScopedGeneratedExtension, parseDelimitedWithIOException, parseDelimitedWithIOException, parseUnknownField, parseUnknownFieldProto3, parseWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, serializeBooleanMapTo, serializeIntegerMapTo, serializeLongMapTo, serializeStringMapTo, writeReplace, writeString, writeStringNoTag, writeTo`

### Methods inherited from class com.google.protobuf.AbstractMessage

`equals, findInitializationErrors, getInitializationErrorString, hashCode, hashFields, newBuilderForType, toString`

### Methods inherited from class com.google.protobuf.AbstractMessageLite

`addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeTo`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface com.google.protobuf.GeneratedMessage.ExtendableMessageOrBuilder

`getDefaultInstanceForType`

### Methods inherited from interface com.google.protobuf.Message

`newBuilderForType, toBuilder`

### Methods inherited from interface com.google.protobuf.MessageLite

`toByteArray, toByteString, writeDelimitedTo, writeTo`

### Methods inherited from interface com.google.protobuf.MessageOrBuilder

`findInitializationErrors, getDescriptorForType, getInitializationErrorString, getOneofFieldDescriptor, getUnknownFields, hasOneof`

## Constructor Details

### ExtendableMessage

protected ExtendableMessage()

### ExtendableMessage

protected ExtendableMessage(GeneratedMessage.ExtendableBuilder<MessageT,?> builder)

## Method Details

### hasExtension

public final <T> boolean hasExtension(ExtensionLite<? extends MessageT,T> extensionLite)
Check if a singular extension is present.

Specified by:
  `hasExtension` in interface `GeneratedMessage.ExtendableMessageOrBuilder<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>`

### getExtensionCount

public final <T> int getExtensionCount(ExtensionLite<? extends MessageT,List<T>> extensionLite)
Get the number of elements in a repeated extension.

Specified by:
  `getExtensionCount` in interface `GeneratedMessage.ExtendableMessageOrBuilder<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>`

### getExtension

public final <T> T getExtension(ExtensionLite<? extends MessageT,T> extensionLite)
Get the value of an extension.

Specified by:
  `getExtension` in interface `GeneratedMessage.ExtendableMessageOrBuilder<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>`

### getExtension

public final <T> T getExtension(ExtensionLite<? extends MessageT,List<T>> extensionLite, int index)
Get one element of a repeated extension.

Specified by:
  `getExtension` in interface `GeneratedMessage.ExtendableMessageOrBuilder<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>`

### extensionsAreInitialized

protected boolean extensionsAreInitialized()
Called by subclasses to check if all extensions are initialized.

### isInitialized

public boolean isInitialized()
Description copied from interface: `MessageLiteOrBuilder`
Returns true if all required fields in the message and all embedded messages are set, false otherwise.

See also: `MessageOrBuilder.getInitializationErrorString()`

Specified by:
  `isInitialized` in interface `MessageLiteOrBuilder`
Overrides:
  `isInitialized` in class `GeneratedMessage`

### newExtensionWriter

@Deprecated protected GeneratedMessage.ExtendableMessage<MessageT>.ExtensionWriter newExtensionWriter()
Deprecated.
Use `newExtensionSerializer()` instead.
For compatibility with older gencode.

TODO Remove this in the next breaking release.

### newExtensionSerializer

protected GeneratedMessage.ExtendableMessage.ExtensionSerializer newExtensionSerializer()

### newMessageSetExtensionWriter

protected GeneratedMessage.ExtendableMessage<MessageT>.ExtensionWriter newMessageSetExtensionWriter()

### newMessageSetExtensionSerializer

protected GeneratedMessage.ExtendableMessage.ExtensionSerializer newMessageSetExtensionSerializer()

### extensionsSerializedSize

protected int extensionsSerializedSize()
Called by subclasses to compute the size of extensions.

### extensionsSerializedSizeAsMessageSet

protected int extensionsSerializedSizeAsMessageSet()

### getExtensionFields

protected Map<Descriptors.FieldDescriptor,Object> getExtensionFields()

### getAllFields

public Map<Descriptors.FieldDescriptor,Object> getAllFields()
Description copied from interface: `MessageOrBuilder`
Returns 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 getRepeatedFieldCount() is greater than zero. The values are exactly what would be returned by calling `MessageOrBuilder.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.

Specified by:
  `getAllFields` in interface `MessageOrBuilder`
Overrides:
  `getAllFields` in class `GeneratedMessage`

### getAllFieldsRaw

public Map<Descriptors.FieldDescriptor,Object> getAllFieldsRaw()

### hasField

public boolean hasField(Descriptors.FieldDescriptor field)
Description copied from interface: `MessageOrBuilder`
Returns true if the given field is set. This is exactly equivalent to calling the generated "has" accessor method corresponding to the field. The return value of hasField() is semantically meaningful only for fields where field.hasPresence() == true.

Specified by:
  `hasField` in interface `MessageOrBuilder`
Overrides:
  `hasField` in class `GeneratedMessage`

### getField

public Object getField(Descriptors.FieldDescriptor field)
Description copied from interface: `MessageOrBuilder`
Obtains 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.

Specified by:
  `getField` in interface `MessageOrBuilder`
Overrides:
  `getField` in class `GeneratedMessage`

### getRepeatedFieldCount

public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Description copied from interface: `MessageOrBuilder`
Gets the number of elements of a repeated field. This is exactly equivalent to calling the generated "Count" accessor method corresponding to the field.

Specified by:
  `getRepeatedFieldCount` in interface `MessageOrBuilder`
Overrides:
  `getRepeatedFieldCount` in class `GeneratedMessage`

### getRepeatedField

public Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
Description copied from interface: `MessageOrBuilder`
Gets 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.

Specified by:
  `getRepeatedField` in interface `MessageOrBuilder`
Overrides:
  `getRepeatedField` in class `GeneratedMessage`