Record Class ProtoMessage

java.lang.Object
java.lang.Record
org.microproxy.contentviews.ProtoMessage
Record Components:
fields - the fields, in wire order
type - the schema type the message was decoded as, or null without a schema

public record ProtoMessage(List<ProtoField> fields, ProtoSchema.MessageType type) extends Record
A decoded protobuf message: its fields in the order they appeared on the wire. Build one by hand to encode it (Protobuf.encode(ProtoMessage)), or get one from Protobuf.decode(byte[]).
  • Constructor Details

    • ProtoMessage

      public ProtoMessage(List<ProtoField> fields, ProtoSchema.MessageType type)
      Copies the field list.
      Parameters:
      fields - the fields, in wire order
      type - the schema type, or null
    • ProtoMessage

      public ProtoMessage(List<ProtoField> fields)
      A message without a schema type.
      Parameters:
      fields - the fields, in wire order
  • Method Details

    • values

      public List<ProtoValue> values(int number)
      The values of field number, in wire order (the elements of a packed field count one by one).
      Parameters:
      number - the field number
      Returns:
      the values, possibly none
    • first

      public Optional<ProtoValue> first(int number)
      The first value of field number.
      Parameters:
      number - the field number
      Returns:
      the value, or empty when the field is absent
    • toPlain

      public Map<Object,Object> toPlain()
      The message as plain Java values, as scripts see it: see Protobuf.toPlain(org.microproxy.contentviews.ProtoMessage).
      Returns:
      a mutable map from field numbers (or declared names) to values
    • render

      public String render()
      The message as readable YAML-like text with field numbers (or declared names), as Protobuf.render(byte[]) shows it.
      Returns:
      the text
    • toString

      public 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • fields

      public List<ProtoField> fields()
      Returns the value of the fields record component.
      Returns:
      the value of the fields record component
    • type

      public ProtoSchema.MessageType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component