Package io.github.zhh2001.jp4.entity
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 wireregister_idduring read response parsing); nevernullindex- the cell index within the register array, as returned by the devicedata- the serialised bytes of thep4.v1.P4Dataproto message the device returned for this cell; nevernull
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 Summary
ConstructorsConstructorDescriptionRegisterEntry(String registerName, long index, Bytes data) Creates an instance of aRegisterEntryrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondata()Returns the value of thedatarecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longindex()Returns the value of theindexrecord component.Returns the value of theregisterNamerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RegisterEntry
Creates an instance of aRegisterEntryrecord class.- Parameters:
registerName- the value for theregisterNamerecord componentindex- the value for theindexrecord componentdata- the value for thedatarecord component
-
-
Method Details
-
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. -
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. -
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 '=='. -
registerName
Returns the value of theregisterNamerecord component.- Returns:
- the value of the
registerNamerecord component
-
index
public long index()Returns the value of theindexrecord component.- Returns:
- the value of the
indexrecord component
-
data
Returns the value of thedatarecord component.- Returns:
- the value of the
datarecord component
-