Record Class AvailablePorts

java.lang.Object
java.lang.Record
pl.polsl.rtsa.api.dto.AvailablePorts
Record Components:
ports - List of available port names.
lastRefreshTime - Unix timestamp of last refresh.

public record AvailablePorts(List<String> ports, long lastRefreshTime) extends Record
Data Transfer Object for available serial ports. Immutable record for thread-safe access.
  • Field Details

    • ports

      private final List<String> ports
      The field for the ports record component.
    • lastRefreshTime

      private final long lastRefreshTime
      The field for the lastRefreshTime record component.
  • Constructor Details

    • AvailablePorts

      public AvailablePorts(List<String> ports, long lastRefreshTime)
      Creates an instance of a AvailablePorts record class.
      Parameters:
      ports - the value for the ports record component
      lastRefreshTime - the value for the lastRefreshTime record component
  • Method Details

    • empty

      public static AvailablePorts empty()
      Creates an empty ports list with timestamp = 0 to force refresh on first use.
    • hasAvailablePorts

      public boolean hasAvailablePorts()
      Checks if any ports are available.
    • count

      public int count()
      Returns the number of available ports.
    • 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.
    • ports

      public List<String> ports()
      Returns the value of the ports record component.
      Returns:
      the value of the ports record component
    • lastRefreshTime

      public long lastRefreshTime()
      Returns the value of the lastRefreshTime record component.
      Returns:
      the value of the lastRefreshTime record component