Record Class CanDeviceId

java.lang.Object
java.lang.Record
frc.spectrumLib.util.CanDeviceId
Record Components:
bus - the bus name, such as "rio" or "canivore", or an empty string for the default bus

public record CanDeviceId(int deviceNumber, String bus) extends Record
Identifies a CAN device by its device number and the bus it lives on. Equality and hashing cover both, so the same device number on two buses stays two distinct devices.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CanDeviceId(int deviceNumber)
    Builds an identifier on the default bus, which is the empty string.
    CanDeviceId(int deviceNumber, String bus)
    Creates an instance of a CanDeviceId record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    bus()
    Returns the value of the bus record component.
    int
    Returns the value of the deviceNumber record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
     
    int
     
    final int
    Returns a hash code value for this object.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • CanDeviceId

      public CanDeviceId(int deviceNumber)
      Builds an identifier on the default bus, which is the empty string.
    • CanDeviceId

      public CanDeviceId(int deviceNumber, String bus)
      Creates an instance of a CanDeviceId record class.
      Parameters:
      deviceNumber - the value for the deviceNumber record component
      bus - the value for the bus record component
  • Method Details

    • getDeviceNumber

      public int getDeviceNumber()
    • getBus

      public String getBus()
    • 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.
    • deviceNumber

      public int deviceNumber()
      Returns the value of the deviceNumber record component.
      Returns:
      the value of the deviceNumber record component
    • bus

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