@Retention(CLASS) @Target({FIELD})

public @interface ProtoField

Binds a ProtoMessage field to a protobuf field tag. Tags must be positive, unique within the message, and correspond to the tag declared in the upstream .proto file.

Optional wireType() forces a non-default scalar encoding for integer fields. Defaults to WireKind.DEFAULT, which selects varint for int32 / int64 / bool, fixed32 / fixed64 for float / double, and length-delimited for strings, byte arrays, nested messages, and repeated packed scalars. Specify WireKind.SINT for ZigZag-encoded signed integers, or WireKind.FIXED for fixed-width unsigned integers (matches fixed32 / fixed64 in proto3).

Nested types

enum ProtoField.WireKindInteger encoding selectors.

Methods

public abstract int tag()Protobuf field tag (positive integer, unique per message).
public abstract String name() default ""Optional override of the Java field name when the generator had to rename it to a valid identifier.
public abstract ProtoField.WireKind wireType() default WireKind.DEFAULTNon-default integer encoding selector.

Method details

tag

public abstract int tag()
Protobuf field tag (positive integer, unique per message).

name

public abstract String name() default ""
Optional override of the Java field name when the generator had to rename it to a valid identifier. Carries the original .proto name so introspection tooling can recover it.

wireType

public abstract ProtoField.WireKind wireType() default WireKind.DEFAULT
Non-default integer encoding selector. Has no effect for non-integer fields.