Package com.google.protobuf

# Class GeneratedMessage.GeneratedExtension<ContainingT extends Message,T>

java.lang.Object
com.google.protobuf.ExtensionLite<ContainingT,T>
com.google.protobuf.Extension<ContainingT,T>
com.google.protobuf.GeneratedMessage.GeneratedExtension<ContainingT,T>

Enclosing class:
  `GeneratedMessage`

public static class GeneratedMessage.GeneratedExtension<ContainingT extends Message,T> extends Extension<ContainingT,T>
Type used to represent generated extensions. The protocol compiler generates a static singleton instance of this class for each extension.

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

     option java_class = "MyProto";

     message Foo {
       extensions 1000 to max;
     }

     extend Foo {
       optional int32 bar;
     }

Then, `MyProto.Foo.bar` has type `GeneratedExtension<MyProto.Foo, Integer>`.

In general, users should ignore the details of this type, and simply use these static singletons as parameters to the extension accessors defined in `GeneratedMessage.ExtendableMessage` and `GeneratedMessage.ExtendableBuilder`.

## Nested Class Summary

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

`Extension.ExtensionType, Extension.MessageType`

## Method Summary

Modifier and Type
Method
Description
`protected Object`
`fromReflectionType(Object value)`
Convert from the type used by the reflection accessors to the type used by native accessors.
`T`
`getDefaultValue()`
Returns the default value of the extension field.
`Descriptors.FieldDescriptor`
`getDescriptor()`
Returns the descriptor of the extension.
`protected Extension.ExtensionType`
`getExtensionType()`
`WireFormat.FieldType`
`getLiteType()`
Returns the type of the field.
`Message`
`getMessageDefaultInstance()`
If the extension is an embedded message or group, returns the default instance of the message.
`int`
`getNumber()`
Returns the field number of the extension.
`void`
`internalInit(Descriptors.FieldDescriptor descriptor)`
For use by generated code only.
`boolean`
`isRepeated()`
Returns whether it is a repeated field.
`protected Object`
`singularFromReflectionType(Object value)`
Like `fromReflectionType(Object)`, but if the type is a repeated type, this converts a single element.
`protected Object`
`singularToReflectionType(Object value)`
Like `toReflectionType(Object)`, but if the type is a repeated type, this converts a single element.
`protected Object`
`toReflectionType(Object value)`
Convert from the type used by the native accessors to the type used by reflection accessors.

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

`getMessageType`

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### internalInit

public void internalInit(Descriptors.FieldDescriptor descriptor)
For use by generated code only.

### getDescriptor

public Descriptors.FieldDescriptor getDescriptor()
Description copied from class: `Extension`
Returns the descriptor of the extension.

Specified by:
  `getDescriptor` in class `Extension<ContainingT extends Message,T>`

### getMessageDefaultInstance

public Message getMessageDefaultInstance()
If the extension is an embedded message or group, returns the default instance of the message.

Specified by:
  `getMessageDefaultInstance` in class `Extension<ContainingT extends Message,T>`

### getExtensionType

protected Extension.ExtensionType getExtensionType()

Specified by:
  `getExtensionType` in class `Extension<ContainingT extends Message,T>`

### fromReflectionType

protected Object fromReflectionType(Object value)
Convert from the type used by the reflection accessors to the type used by native accessors. E.g., for enums, the reflection accessors use EnumValueDescriptors but the native accessors use the generated enum type.

Specified by:
  `fromReflectionType` in class `Extension<ContainingT extends Message,T>`

### singularFromReflectionType

protected Object singularFromReflectionType(Object value)
Like `fromReflectionType(Object)`, but if the type is a repeated type, this converts a single element.

Specified by:
  `singularFromReflectionType` in class `Extension<ContainingT extends Message,T>`

### toReflectionType

protected Object toReflectionType(Object value)
Convert from the type used by the native accessors to the type used by reflection accessors. E.g., for enums, the reflection accessors use EnumValueDescriptors but the native accessors use the generated enum type.

Specified by:
  `toReflectionType` in class `Extension<ContainingT extends Message,T>`

### singularToReflectionType

protected Object singularToReflectionType(Object value)
Like `toReflectionType(Object)`, but if the type is a repeated type, this converts a single element.

Specified by:
  `singularToReflectionType` in class `Extension<ContainingT extends Message,T>`

### getNumber

public int getNumber()
Description copied from class: `ExtensionLite`
Returns the field number of the extension.

Specified by:
  `getNumber` in class `ExtensionLite<ContainingT extends Message,T>`

### getLiteType

public WireFormat.FieldType getLiteType()
Description copied from class: `ExtensionLite`
Returns the type of the field.

Specified by:
  `getLiteType` in class `ExtensionLite<ContainingT extends Message,T>`

### isRepeated

public boolean isRepeated()
Description copied from class: `ExtensionLite`
Returns whether it is a repeated field.

Specified by:
  `isRepeated` in class `ExtensionLite<ContainingT extends Message,T>`

### getDefaultValue

public T getDefaultValue()
Description copied from class: `ExtensionLite`
Returns the default value of the extension field.

Specified by:
  `getDefaultValue` in class `ExtensionLite<ContainingT extends Message,T>`