Class GeneratedMessage.GeneratedExtension<ContainingType,Type> (3.19.4)

public static class GeneratedMessage.GeneratedExtension<ContainingType,Type> extends Extension<ContainingType,Type>

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 ExtendableMessage and ExtendableBuilder.

Inheritance

Object > ExtensionLite<ContainingType,Type> > Extension > GeneratedMessage.GeneratedExtension<ContainingType,Type>

Type Parameters

Name Description
ContainingType
Type

Methods

fromReflectionType(Object value)

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.

Parameter
Name Description
value Object
Returns
Type Description
Object
Overrides

getDefaultValue()

public Type getDefaultValue()

Returns the default value of the extension field.

Returns
Type Description
Type
Overrides

getDescriptor()

public Descriptors.FieldDescriptor getDescriptor()

Returns the descriptor of the extension.

Returns
Type Description
Descriptors.FieldDescriptor
Overrides

getExtensionType()

protected Extension.ExtensionType getExtensionType()
Returns
Type Description
Extension.ExtensionType
Overrides

getLiteType()

public WireFormat.FieldType getLiteType()

Returns the type of the field.

Returns
Type Description
WireFormat.FieldType
Overrides

getMessageDefaultInstance()

public Message getMessageDefaultInstance()

If the extension is an embedded message or group, returns the default instance of the message.

Returns
Type Description
Message
Overrides

getNumber()

public int getNumber()

Returns the field number of the extension.

Returns
Type Description
int
Overrides

internalInit(Descriptors.FieldDescriptor descriptor)

public void internalInit(Descriptors.FieldDescriptor descriptor)

For use by generated code only.

Parameter
Name Description
descriptor Descriptors.FieldDescriptor

isRepeated()

public boolean isRepeated()

Returns whether it is a repeated field.

Returns
Type Description
boolean
Overrides

singularFromReflectionType(Object value)

protected Object singularFromReflectionType(Object value)

Like #fromReflectionType(Object), but if the type is a repeated type, this converts a single element.

Parameter
Name Description
value Object
Returns
Type Description
Object
Overrides

singularToReflectionType(Object value)

protected Object singularToReflectionType(Object value)

Like #toReflectionType(Object), but if the type is a repeated type, this converts a single element.

Parameter
Name Description
value Object
Returns
Type Description
Object
Overrides

toReflectionType(Object value)

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.

Parameter
Name Description
value Object
Returns
Type Description
Object
Overrides