Annotation Type ProtoReserved
@Target(TYPE)
@Retention(RUNTIME)
@Documented
@Repeatable(ProtoReservedStatements.class)
public @interface 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
Modifier and TypeClassDescriptionstatic @interface
A range of field numbers or enum constants. -
Optional Element Summary
-
Element Details
-
value
int[] valueAlias fornumbers()
(mutually exclusive).- Default:
- {}
-
numbers
int[] numbersNumbers to reserve. Alias forvalue()
(mutually exclusive).- Default:
- {}
-
ranges
ProtoReserved.Range[] rangesNumber ranges to be reserved.- Default:
- {}
-
names
String[] namesNames to be reserved.- Default:
- {}
-