Record Class DeviceInfo

java.lang.Object
java.lang.Record
xbot.common.injection.electrical_contract.DeviceInfo
Record Components:
name - device name
channel - channel or device number
inverted - whether the device's reading is inverted
canBusId - CAN bus identity, ignored by non-CAN devices
powerFrom - power-source metadata

public record DeviceInfo(String name, int channel, boolean inverted, CANBusId canBusId, PowerSource powerFrom) extends Record
Immutable device configuration. Construction does not validate or reserve hardware.
DeviceInfo encoder = DeviceInfo.builder("SteeringEncoder").withCanBus(CANPort.CAN_S1, 11).withInverted(true).build();
  • Constructor Details

    • DeviceInfo

      public DeviceInfo(String name, int channel, boolean inverted, CANBusId canBusId, PowerSource powerFrom)
      Creates an instance of a DeviceInfo record class.
      Parameters:
      name - the value for the name record component
      channel - the value for the channel record component
      inverted - the value for the inverted record component
      canBusId - the value for the canBusId record component
      powerFrom - the value for the powerFrom record component
  • Method Details

    • builder

      public static DeviceInfo.Builder builder(String name)
      Starts a builder with no inversion, CAN_S0, and no power-source metadata. Set a non-CAN channel with DeviceInfo.Builder.withChannel(int), or a CAN address with DeviceInfo.Builder.withCanBus(CANPort, int). An unspecified channel is -1.
    • 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.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • channel

      public int channel()
      Returns the value of the channel record component.
      Returns:
      the value of the channel record component
    • inverted

      public boolean inverted()
      Returns the value of the inverted record component.
      Returns:
      the value of the inverted record component
    • canBusId

      public CANBusId canBusId()
      Returns the value of the canBusId record component.
      Returns:
      the value of the canBusId record component
    • powerFrom

      public PowerSource powerFrom()
      Returns the value of the powerFrom record component.
      Returns:
      the value of the powerFrom record component