Record Class RegisterEntry

java.lang.Object
java.lang.Record
io.github.zhh2001.jp4.entity.RegisterEntry
Record Components:
registerName - the register's fully-qualified P4 name (resolved from the wire register_id during read response parsing); never null
index - the cell index within the register array, as returned by the device
data - the serialised bytes of the p4.v1.P4Data proto message the device returned for this cell; never null

public record RegisterEntry(String registerName, long index, Bytes data) extends Record
One P4 register cell returned by P4Switch.readRegister. The record carries the register's fully-qualified P4 name, the cell index within the register array, and the cell's payload as the serialised bytes of one p4.v1.P4Data message.

The payload is intentionally kept as raw bytes: a register's per-cell type is declared in P4Info as a P4DataTypeSpec, and surfacing typed values would require a P4Info-aware decoder that is held for a future v1.x release. The same convention is in force for DigestEvent.data.

Consumers that want the typed form decode through the generated proto class:


 P4Data datum = P4DataOuterClass.P4Data.parseFrom(entry.data().toByteArray());
 // For the common bit<W> / int<W> register, the payload is the bitstring oneof:
 Bytes value = Bytes.of(datum.getBitstring().toByteArray());
 

Records are immutable. The canonical constructor rejects null in every reference component; the long index has no null surface.

Since:
1.4.0
  • Constructor Details

    • RegisterEntry

      public RegisterEntry(String registerName, long index, Bytes data)
      Creates an instance of a RegisterEntry record class.
      Parameters:
      registerName - the value for the registerName record component
      index - the value for the index record component
      data - the value for the data record component
  • Method Details

    • 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 '=='.
      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.
    • registerName

      public String registerName()
      Returns the value of the registerName record component.
      Returns:
      the value of the registerName record component
    • index

      public long index()
      Returns the value of the index record component.
      Returns:
      the value of the index record component
    • data

      public Bytes data()
      Returns the value of the data record component.
      Returns:
      the value of the data record component