Record Class ConnectionStatus

java.lang.Object
java.lang.Record
pl.polsl.rtsa.api.dto.ConnectionStatus
Record Components:
connected - Whether a device is currently connected.
portName - The name of the connected port, or null if not connected.
deviceInfo - Device identification string from handshake, or null.

public record ConnectionStatus(boolean connected, String portName, String deviceInfo) extends Record
Data Transfer Object representing the connection state. Immutable record for thread-safe access.
  • Field Details

    • connected

      private final boolean connected
      The field for the connected record component.
    • portName

      private final String portName
      The field for the portName record component.
    • deviceInfo

      private final String deviceInfo
      The field for the deviceInfo record component.
  • Constructor Details

    • ConnectionStatus

      public ConnectionStatus(boolean connected, String portName, String deviceInfo)
      Creates an instance of a ConnectionStatus record class.
      Parameters:
      connected - the value for the connected record component
      portName - the value for the portName record component
      deviceInfo - the value for the deviceInfo record component
  • Method Details

    • disconnected

      public static ConnectionStatus disconnected()
      Creates a disconnected status.
    • connected

      public static ConnectionStatus connected(String portName, String deviceInfo)
      Creates a connected status.
      Parameters:
      portName - The connected port name.
      deviceInfo - Device identification info.
    • 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.
    • connected

      public boolean connected()
      Returns the value of the connected record component.
      Returns:
      the value of the connected record component
    • portName

      public String portName()
      Returns the value of the portName record component.
      Returns:
      the value of the portName record component
    • deviceInfo

      public String deviceInfo()
      Returns the value of the deviceInfo record component.
      Returns:
      the value of the deviceInfo record component