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

NameDescription
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
NameDescription
valueObject
Returns
TypeDescription
Object
Overrides

getDefaultValue()

public Type getDefaultValue()

Returns the default value of the extension field.

Returns
TypeDescription
Type
Overrides

getDescriptor()

public Descriptors.FieldDescriptor getDescriptor()

Returns the descriptor of the extension.

Returns
TypeDescription
Descriptors.FieldDescriptor
Overrides

getExtensionType()

protected Extension.ExtensionType getExtensionType()
Returns
TypeDescription
Extension.ExtensionType
Overrides

getLiteType()

public WireFormat.FieldType getLiteType()

Returns the type of the field.

Returns
TypeDescription
WireFormat.FieldType
Overrides

getMessageDefaultInstance()

public Message getMessageDefaultInstance()

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

Returns
TypeDescription
Message
Overrides

getNumber()

public int getNumber()

Returns the field number of the extension.

Returns
TypeDescription
int
Overrides

internalInit(Descriptors.FieldDescriptor descriptor)

public void internalInit(Descriptors.FieldDescriptor descriptor)

For use by generated code only.

Parameter
NameDescription
descriptorDescriptors.FieldDescriptor

isRepeated()

public boolean isRepeated()

Returns whether it is a repeated field.

Returns
TypeDescription
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
NameDescription
valueObject
Returns
TypeDescription
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
NameDescription
valueObject
Returns
TypeDescription
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
NameDescription
valueObject
Returns
TypeDescription
Object
Overrides