Record Class ProtoProperty
java.lang.Object
java.lang.Record
io.micronaut.serde.protobuf.ProtoProperty
- Record Components:
name- The serde property namenumber- The protobuf field numbertype- The declared wire representationargument- The resolved serde property typerepeatedField- Whether the property is a repeated fieldpackableElement- Whether the element type is a scalar that protobuf packs by defaultbytesField- Whether the property is abytesfield rather than a repeated onerepeatedBytesField- Whether each repeated element is abytesvaluemessageField- Whether duplicate occurrences should be merged as embedded messagesexplicitPresence- Whether scalar defaults must be retained on the wireopaqueWireType- Whether the wire type cannot be predicted from the Java type, because the property is serialized by a serde of its own choosingwireType- The expected wire type for one valuevarintTag- The pre-combined tag for a varint valuefixed32Tag- The pre-combined tag for a four-byte valuefixed64Tag- The pre-combined tag for an eight-byte valuelengthTag- The pre-combined tag for a length-delimited valueintKind- Howint-width values are encoded, one of theKIND_constantslongKind- Howlong-width values are encoded, one of theKIND_constantszigZag32- Whether zig-zag values are narrowed to 32 bits before decoding, assint32requires
@Internal
public record ProtoProperty(String name, int number, ProtoType type, io.micronaut.core.type.Argument<?> argument, boolean repeatedField, boolean packableElement, boolean bytesField, boolean repeatedBytesField, boolean messageField, boolean explicitPresence, boolean opaqueWireType, int wireType, int varintTag, int fixed32Tag, int fixed64Tag, int lengthTag, int intKind, int longKind, boolean zigZag32)
extends Record
One property of a message, with everything the encoder and decoder need already computed.
Field tags and the choice between varint, zig-zag and fixed-width encoding follow from the
declared ProtoType, which never changes. Resolving them once here keeps the per-value
path down to an integer switch and a write, with no annotation or enum lookups.
- Since:
- 3.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA fixed four-byte value.static final intA fixed eight-byte value.static final intA plain varint, sign-extending negative values to ten bytes.static final intA plain varint over the full 64-bit value.static final intA varint over the unsigned 32-bit value.static final intA varint over the zig-zag encoding, so small negative values stay small. -
Constructor Summary
ConstructorsConstructorDescriptionProtoProperty(String name, int number, ProtoType type, io.micronaut.core.type.Argument<?> argument, boolean repeatedField, boolean packableElement, boolean bytesField, boolean repeatedBytesField, boolean messageField, boolean explicitPresence, boolean opaqueWireType, int wireType, int varintTag, int fixed32Tag, int fixed64Tag, int lengthTag, int intKind, int longKind, boolean zigZag32) Creates an instance of aProtoPropertyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.core.type.Argument<?> argument()Returns the value of theargumentrecord component.booleanReturns the value of thebytesFieldrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanReturns the value of theexplicitPresencerecord component.intReturns the value of thefixed32Tagrecord component.intReturns the value of thefixed64Tagrecord component.final inthashCode()Returns a hash code value for this object.intintKind()Returns the value of theintKindrecord component.intReturns the value of thelengthTagrecord component.intlongKind()Returns the value of thelongKindrecord component.booleanReturns the value of themessageFieldrecord component.name()Returns the value of thenamerecord component.intnumber()Returns the value of thenumberrecord component.booleanReturns the value of theopaqueWireTyperecord component.booleanReturns the value of thepackableElementrecord component.booleanReturns the value of therepeatedBytesFieldrecord component.booleanReturns the value of therepeatedFieldrecord component.inttagFor(int kind) The pre-combined tag for a value of the given kind.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.intReturns the value of thevarintTagrecord component.intwireTag()The pre-combined tag for this property's expected wire type.intwireType()Returns the value of thewireTyperecord component.static intwireTypeOf(int kind) The wire type a value of the given kind travels under.booleanzigZag32()Returns the value of thezigZag32record component.
-
Field Details
-
KIND_INT32
public static final int KIND_INT32A plain varint, sign-extending negative values to ten bytes.- See Also:
-
KIND_INT64
public static final int KIND_INT64A plain varint over the full 64-bit value.- See Also:
-
KIND_ZIGZAG
public static final int KIND_ZIGZAGA varint over the zig-zag encoding, so small negative values stay small.- See Also:
-
KIND_UINT32
public static final int KIND_UINT32A varint over the unsigned 32-bit value.- See Also:
-
KIND_FIXED32
public static final int KIND_FIXED32A fixed four-byte value.- See Also:
-
KIND_FIXED64
public static final int KIND_FIXED64A fixed eight-byte value.- See Also:
-
-
Constructor Details
-
ProtoProperty
public ProtoProperty(String name, int number, ProtoType type, io.micronaut.core.type.Argument<?> argument, boolean repeatedField, boolean packableElement, boolean bytesField, boolean repeatedBytesField, boolean messageField, boolean explicitPresence, boolean opaqueWireType, int wireType, int varintTag, int fixed32Tag, int fixed64Tag, int lengthTag, int intKind, int longKind, boolean zigZag32) Creates an instance of aProtoPropertyrecord class.- Parameters:
name- the value for thenamerecord componentnumber- the value for thenumberrecord componenttype- the value for thetyperecord componentargument- the value for theargumentrecord componentrepeatedField- the value for therepeatedFieldrecord componentpackableElement- the value for thepackableElementrecord componentbytesField- the value for thebytesFieldrecord componentrepeatedBytesField- the value for therepeatedBytesFieldrecord componentmessageField- the value for themessageFieldrecord componentexplicitPresence- the value for theexplicitPresencerecord componentopaqueWireType- the value for theopaqueWireTyperecord componentwireType- the value for thewireTyperecord componentvarintTag- the value for thevarintTagrecord componentfixed32Tag- the value for thefixed32Tagrecord componentfixed64Tag- the value for thefixed64Tagrecord componentlengthTag- the value for thelengthTagrecord componentintKind- the value for theintKindrecord componentlongKind- the value for thelongKindrecord componentzigZag32- the value for thezigZag32record component
-
-
Method Details
-
wireTypeOf
public static int wireTypeOf(int kind) The wire type a value of the given kind travels under.- Parameters:
kind- One of theKIND_constants- Returns:
- The wire type
-
tagFor
public int tagFor(int kind) The pre-combined tag for a value of the given kind.- Parameters:
kind- One of theKIND_constants- Returns:
- The tag
-
wireTag
public int wireTag()The pre-combined tag for this property's expected wire type.- Returns:
- The tag
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
name
-
number
-
type
-
argument
-
repeatedField
public boolean repeatedField()Returns the value of therepeatedFieldrecord component.- Returns:
- the value of the
repeatedFieldrecord component
-
packableElement
public boolean packableElement()Returns the value of thepackableElementrecord component.- Returns:
- the value of the
packableElementrecord component
-
bytesField
public boolean bytesField()Returns the value of thebytesFieldrecord component.- Returns:
- the value of the
bytesFieldrecord component
-
repeatedBytesField
public boolean repeatedBytesField()Returns the value of therepeatedBytesFieldrecord component.- Returns:
- the value of the
repeatedBytesFieldrecord component
-
messageField
public boolean messageField()Returns the value of themessageFieldrecord component.- Returns:
- the value of the
messageFieldrecord component
-
explicitPresence
public boolean explicitPresence()Returns the value of theexplicitPresencerecord component.- Returns:
- the value of the
explicitPresencerecord component
-
opaqueWireType
public boolean opaqueWireType()Returns the value of theopaqueWireTyperecord component.- Returns:
- the value of the
opaqueWireTyperecord component
-
wireType
-
varintTag
-
fixed32Tag
public int fixed32Tag()Returns the value of thefixed32Tagrecord component.- Returns:
- the value of the
fixed32Tagrecord component
-
fixed64Tag
public int fixed64Tag()Returns the value of thefixed64Tagrecord component.- Returns:
- the value of the
fixed64Tagrecord component
-
lengthTag
-
intKind
-
longKind
-
zigZag32
-