Class GeneratedMessage.GeneratedExtension<ContainingType extends Message,Type>

  • Enclosing class:
    GeneratedMessage


    public static class GeneratedMessage.GeneratedExtension<ContainingType extends Message,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 GeneratedMessage.ExtendableMessage and GeneratedMessage.ExtendableBuilder.

    • Method Detail

      • getMessageDefaultInstance

        public Message getMessageDefaultInstance()
        If the extension is an embedded message or group, returns the default instance of the message.
      • 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.
      • 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.
      • singularToReflectionType

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

        public int getNumber()
        Description copied from class: Extension
        Returns the field number of the extension.
      • isRepeated

        public boolean isRepeated()
        Description copied from class: Extension
        Returns whether it is a repeated field.
      • getDefaultValue

        public Type getDefaultValue()
        Description copied from class: Extension
        Returns the default value of the extension field.