com.qualcomm.robotcore.util

## Class SerialNumber

- java.lang.Object
- - com.qualcomm.robotcore.util.SerialNumber

- All Implemented Interfaces:
    java.io.Serializable

      public abstract class SerialNumber
      extends java.lang.Object
      implements java.io.Serializable

  Instances of `SerialNumber` represent serial number indentifiers of hardware devices. For USB-attached devices, these are usually the low-level USB serial number (see `UsbDevice#getSerialNumber()`, but that is not required. Rather, the notion of `SerialNumber` is a general purpose one representing a user-visible digital identity for a particular device instance. 'Fake' serial numbers are serial numbers that will *never* appear for a real device; they are useful, for example, as the serial number of a `ControllerConfiguration` that has not yet been associated with a actual controller device. Fake serial numbers are never shown to users. Note that *all* serial numbers loaded in memory at any given instant are guaranteed unique and different, even the fake ones; this allows code that processes USB-device-bound `ControllerConfiguration`s to operate easily on unbound ones as well, a significant coding simplification. The technology used in fake serial numbers, `UUID`s, in fact guarantees uniqueness across space and time, so fake serial numbers can be recorded persistently and still maintain uniqueness. Historically, non-unique 'fake' serial numbers were also used: these appeared int the form of "-1" or "N/A". When loaded from persistent storage, such legacy fake serial numbers are converted to unique ones to maintain the uniqueness guarantee.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.util.HashMap<java.lang.String,java.lang.String>` | `deviceDisplayNames`
    `protected static java.lang.String` | `embedded`
    `protected static java.lang.String` | `fakePrefix`
    `protected static java.lang.String` | `lynxModulePrefix`
    `protected java.lang.String` | `serialNumberString`
    `protected static java.lang.String` | `vendorProductPrefix`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SerialNumber(java.lang.String serialNumberString)` Constructs a serial number using the supplied initialization string.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static SerialNumber` | `createEmbedded()`
    `static SerialNumber` | `createFake()`
    `boolean` | `equals(java.lang.Object object)`
    `boolean` | `equals(java.lang.String string)`
    `static SerialNumber` | `fromString(java.lang.String serialNumberString)`
    `static SerialNumber` | `fromStringOrNull(java.lang.String serialNumberString)`
    `static SerialNumber` | `fromUsbOrNull(java.lang.String serialNumberString)`
    `static SerialNumber` | `fromVidPid(int vid, int pid, java.lang.String connectionPath)` Makes up a serial-number-like-thing for USB devices that internally lack a serial number.
    `static java.lang.String` | `getDeviceDisplayName(SerialNumber serialNumber)`
    `SerialNumber` | `getScannableDeviceSerialNumber()` Returns the `SerialNumber` of the device associated with this one that would appear in a `ScannedDevices`.
    `java.lang.String` | `getString()` Returns the string contents of the serial number.
    `int` | `hashCode()`
    `boolean` | `isEmbedded()` Returns whether the serial number is the one used for the embedded Expansion Hub inside a Rev Control Hub.
    `boolean` | `isFake()` Returns whether the indicated serial number is one of the legacy fake serial number forms or not.
    `boolean` | `isUsb()` Returns whether the serial number is one of an actual USB device.
    `boolean` | `isVendorProduct()`
    `boolean` | `matches(java.lang.Object pattern)`
    `static void` | `noteSerialNumberType(SerialNumber serialNumber, java.lang.String typeName)`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### fakePrefix

          protected static final java.lang.String fakePrefix

      See Also:
        Constant Field Values

    - #### vendorProductPrefix

          protected static final java.lang.String vendorProductPrefix

      See Also:
        Constant Field Values

    - #### lynxModulePrefix

          protected static final java.lang.String lynxModulePrefix

      See Also:
        Constant Field Values

    - #### embedded

          protected static final java.lang.String embedded

      See Also:
        Constant Field Values

    - #### serialNumberString

          protected final java.lang.String serialNumberString

    - #### deviceDisplayNames

          protected static final java.util.HashMap<java.lang.String,java.lang.String> deviceDisplayNames

  - ### Constructor Detail

    - #### SerialNumber

          protected SerialNumber(java.lang.String serialNumberString)

      Constructs a serial number using the supplied initialization string. If the initialization string is a legacy form of fake serial number, a unique fake serial number is created.
      Parameters:
        `serialNumberString` - the initialization string for the serial number.

  - ### Method Detail

    - #### createFake

          public static SerialNumber createFake()

    - #### createEmbedded

          public static SerialNumber createEmbedded()

    - #### fromString

          public static SerialNumber fromString(java.lang.String serialNumberString)

    - #### fromStringOrNull

          public static SerialNumber fromStringOrNull(java.lang.String serialNumberString)

    - #### fromUsbOrNull

          public static SerialNumber fromUsbOrNull(java.lang.String serialNumberString)

    - #### fromVidPid

          public static SerialNumber fromVidPid(int vid,
                                                int pid,
                                                java.lang.String connectionPath)

      Makes up a serial-number-like-thing for USB devices that internally lack a serial number.

    - #### isVendorProduct

          public boolean isVendorProduct()

    - #### isFake

          public boolean isFake()

      Returns whether the indicated serial number is one of the legacy fake serial number forms or not.
      Returns:
        whether the the serial number is a legacy fake form of serial number

    - #### isUsb

          public boolean isUsb()

      Returns whether the serial number is one of an actual USB device.

    - #### isEmbedded

          public boolean isEmbedded()

      Returns whether the serial number is the one used for the embedded Expansion Hub inside a Rev Control Hub.

    - #### getString

          public java.lang.String getString()

      Returns the string contents of the serial number. Result is not intended to be displayed to humans.
      See Also:
        `Object.toString()`

    - #### getScannableDeviceSerialNumber

          public SerialNumber getScannableDeviceSerialNumber()

      Returns the `SerialNumber` of the device associated with this one that would appear in a `ScannedDevices`.

    - #### matches

          public boolean matches(java.lang.Object pattern)

    - #### equals

          public boolean equals(java.lang.Object object)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.String string)

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### noteSerialNumberType

          public static void noteSerialNumberType(SerialNumber serialNumber,
                                                  java.lang.String typeName)

    - #### getDeviceDisplayName

          public static java.lang.String getDeviceDisplayName(SerialNumber serialNumber)