Record Class ProtoProperty

java.lang.Object
java.lang.Record
io.micronaut.serde.protobuf.ProtoProperty
Record Components:
name - The serde property name
number - The protobuf field number
type - The declared wire representation
argument - The resolved serde property type
repeatedField - Whether the property is a repeated field
packableElement - Whether the element type is a scalar that protobuf packs by default
bytesField - Whether the property is a bytes field rather than a repeated one
repeatedBytesField - Whether each repeated element is a bytes value
messageField - Whether duplicate occurrences should be merged as embedded messages
explicitPresence - Whether scalar defaults must be retained on the wire
opaqueWireType - Whether the wire type cannot be predicted from the Java type, because the property is serialized by a serde of its own choosing
wireType - The expected wire type for one value
varintTag - The pre-combined tag for a varint value
fixed32Tag - The pre-combined tag for a four-byte value
fixed64Tag - The pre-combined tag for an eight-byte value
lengthTag - The pre-combined tag for a length-delimited value
intKind - How int-width values are encoded, one of the KIND_ constants
longKind - How long-width values are encoded, one of the KIND_ constants
zigZag32 - Whether zig-zag values are narrowed to 32 bits before decoding, as sint32 requires

@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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    A fixed four-byte value.
    static final int
    A fixed eight-byte value.
    static final int
    A plain varint, sign-extending negative values to ten bytes.
    static final int
    A plain varint over the full 64-bit value.
    static final int
    A varint over the unsigned 32-bit value.
    static final int
    A varint over the zig-zag encoding, so small negative values stay small.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 a ProtoProperty record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    io.micronaut.core.type.Argument<?>
    Returns the value of the argument record component.
    boolean
    Returns the value of the bytesField record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
    Returns the value of the explicitPresence record component.
    int
    Returns the value of the fixed32Tag record component.
    int
    Returns the value of the fixed64Tag record component.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the intKind record component.
    int
    Returns the value of the lengthTag record component.
    int
    Returns the value of the longKind record component.
    boolean
    Returns the value of the messageField record component.
    Returns the value of the name record component.
    int
    Returns the value of the number record component.
    boolean
    Returns the value of the opaqueWireType record component.
    boolean
    Returns the value of the packableElement record component.
    boolean
    Returns the value of the repeatedBytesField record component.
    boolean
    Returns the value of the repeatedField record component.
    int
    tagFor(int kind)
    The pre-combined tag for a value of the given kind.
    final String
    Returns a string representation of this record class.
    Returns the value of the type record component.
    int
    Returns the value of the varintTag record component.
    int
    The pre-combined tag for this property's expected wire type.
    int
    Returns the value of the wireType record component.
    static int
    wireTypeOf(int kind)
    The wire type a value of the given kind travels under.
    boolean
    Returns the value of the zigZag32 record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • KIND_INT32

      public static final int KIND_INT32
      A plain varint, sign-extending negative values to ten bytes.
      See Also:
    • KIND_INT64

      public static final int KIND_INT64
      A plain varint over the full 64-bit value.
      See Also:
    • KIND_ZIGZAG

      public static final int KIND_ZIGZAG
      A varint over the zig-zag encoding, so small negative values stay small.
      See Also:
    • KIND_UINT32

      public static final int KIND_UINT32
      A varint over the unsigned 32-bit value.
      See Also:
    • KIND_FIXED32

      public static final int KIND_FIXED32
      A fixed four-byte value.
      See Also:
    • KIND_FIXED64

      public static final int KIND_FIXED64
      A 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 a ProtoProperty record class.
      Parameters:
      name - the value for the name record component
      number - the value for the number record component
      type - the value for the type record component
      argument - the value for the argument record component
      repeatedField - the value for the repeatedField record component
      packableElement - the value for the packableElement record component
      bytesField - the value for the bytesField record component
      repeatedBytesField - the value for the repeatedBytesField record component
      messageField - the value for the messageField record component
      explicitPresence - the value for the explicitPresence record component
      opaqueWireType - the value for the opaqueWireType record component
      wireType - the value for the wireType record component
      varintTag - the value for the varintTag record component
      fixed32Tag - the value for the fixed32Tag record component
      fixed64Tag - the value for the fixed64Tag record component
      lengthTag - the value for the lengthTag record component
      intKind - the value for the intKind record component
      longKind - the value for the longKind record component
      zigZag32 - the value for the zigZag32 record 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 the KIND_ 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 the KIND_ constants
      Returns:
      The tag
    • wireTag

      public int wireTag()
      The pre-combined tag for this property's expected wire type.
      Returns:
      The tag
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • number

      public int number()
      Returns the value of the number record component.
      Returns:
      the value of the number record component
    • type

      public ProtoType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • argument

      public io.micronaut.core.type.Argument<?> argument()
      Returns the value of the argument record component.
      Returns:
      the value of the argument record component
    • repeatedField

      public boolean repeatedField()
      Returns the value of the repeatedField record component.
      Returns:
      the value of the repeatedField record component
    • packableElement

      public boolean packableElement()
      Returns the value of the packableElement record component.
      Returns:
      the value of the packableElement record component
    • bytesField

      public boolean bytesField()
      Returns the value of the bytesField record component.
      Returns:
      the value of the bytesField record component
    • repeatedBytesField

      public boolean repeatedBytesField()
      Returns the value of the repeatedBytesField record component.
      Returns:
      the value of the repeatedBytesField record component
    • messageField

      public boolean messageField()
      Returns the value of the messageField record component.
      Returns:
      the value of the messageField record component
    • explicitPresence

      public boolean explicitPresence()
      Returns the value of the explicitPresence record component.
      Returns:
      the value of the explicitPresence record component
    • opaqueWireType

      public boolean opaqueWireType()
      Returns the value of the opaqueWireType record component.
      Returns:
      the value of the opaqueWireType record component
    • wireType

      public int wireType()
      Returns the value of the wireType record component.
      Returns:
      the value of the wireType record component
    • varintTag

      public int varintTag()
      Returns the value of the varintTag record component.
      Returns:
      the value of the varintTag record component
    • fixed32Tag

      public int fixed32Tag()
      Returns the value of the fixed32Tag record component.
      Returns:
      the value of the fixed32Tag record component
    • fixed64Tag

      public int fixed64Tag()
      Returns the value of the fixed64Tag record component.
      Returns:
      the value of the fixed64Tag record component
    • lengthTag

      public int lengthTag()
      Returns the value of the lengthTag record component.
      Returns:
      the value of the lengthTag record component
    • intKind

      public int intKind()
      Returns the value of the intKind record component.
      Returns:
      the value of the intKind record component
    • longKind

      public int longKind()
      Returns the value of the longKind record component.
      Returns:
      the value of the longKind record component
    • zigZag32

      public boolean zigZag32()
      Returns the value of the zigZag32 record component.
      Returns:
      the value of the zigZag32 record component