Annotation Type ProtoEnum


@Retention(CLASS) @Target(TYPE) public @interface ProtoEnum

Marks a Java enum as a Protocol Buffers enum. The generator emits the enum with a public final int number field and a static Xxx forNumber(int n) lookup. On the wire enums are encoded as varint -- the field's tag from ProtoField is read / written like an int32, and the integer value is mapped back to the enum constant via forNumber.

Unknown numbers map to null so callers can distinguish "no such constant" from "constant with number 0". For proto3 the zero constant is the default and is what the wire produces when the field is absent.