Annotation Type ProtoReserved


Injects 'reserved' statements in the generated schema of a message or enum type. The 'reserved' statement is added inside the generated message or enum definition, right at the beginning. Mixing numbers, ranges and names in a single annotation instance is allowed (for your convenience) but results in separate statements being generated for numbers and names because protobuf does not allow mixing them.

All ProtoReserved annotations from the superclass and implemented/extended interfaces are inherited (recursively up the hierarchy) and the numbers, ranges and names are merged. No duplicates or overlaps must be found in the process or else an error will be generated. Regardless of how many annotations are found, after merging at most two 'reserved' statements will be issued, one for numbers/ranges and one for names. Their contents will be sorted ascendingly.

This annotation is not explicitly marked Inherited but annotation processors will scan for occurrences of this annotation in all superclasses and superinterfaces (recursively).

Since:
4.3
Author:
[email protected]
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    A range of field numbers or enum constants.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Names to be reserved.
    int[]
    Numbers to reserve.
    Number ranges to be reserved.
    int[]
    Alias for numbers() (mutually exclusive).
  • Element Details

    • value

      int[] value
      Alias for numbers() (mutually exclusive).
      Default:
      {}
    • numbers

      int[] numbers
      Numbers to reserve. Alias for value() (mutually exclusive).
      Default:
      {}
    • ranges

      Number ranges to be reserved.
      Default:
      {}
    • names

      String[] names
      Names to be reserved.
      Default:
      {}