Record Class CopilotWebSocketMessage

java.lang.Object
java.lang.Record
com.github.copilot.CopilotWebSocketMessage
Record Components:
data - the message payload bytes
binary - true for a binary frame, false for a UTF-8 text frame

public record CopilotWebSocketMessage(byte[] data, boolean binary) extends Record
A single WebSocket message exchanged through a CopilotWebSocketHandler hook.
Since:
1.0.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    CopilotWebSocketMessage(byte[] data, boolean binary)
    Creates an instance of a CopilotWebSocketMessage record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the value of the binary record component.
    byte[]
    Returns the value of the data record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Creates a text message from a UTF-8 string.
    final int
    Returns a hash code value for this object.
    Decodes the payload as UTF-8 text.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

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

    • CopilotWebSocketMessage

      public CopilotWebSocketMessage(byte[] data, boolean binary)
      Creates an instance of a CopilotWebSocketMessage record class.
      Parameters:
      data - the value for the data record component
      binary - the value for the binary record component
  • Method Details

    • text

      public String text()
      Decodes the payload as UTF-8 text.
      Returns:
      the payload as text
    • fromText

      public static CopilotWebSocketMessage fromText(String text)
      Creates a text message from a UTF-8 string.
      Parameters:
      text - the text payload
      Returns:
      a text message
    • 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.
    • data

      public byte[] data()
      Returns the value of the data record component.
      Returns:
      the value of the data record component
    • binary

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