Class USBDeviceFilter

java.lang.Object
net.codecrete.usb.USBDeviceFilter

public class USBDeviceFilter extends Object
Filter condition for matching USB devices.

In order to match this condition, all non-null properties of this instance must be equal to the same properties of the USB device.

For a well implemented USB device, the combination of vendor ID, product ID and serial number is globally unique.

  • Constructor Details

    • USBDeviceFilter

      public USBDeviceFilter()
      Creates a new instance.
    • USBDeviceFilter

      public USBDeviceFilter(int vendorId, int productId)
      Creates a new instance that matches the specified vendor and product ID.
      Parameters:
      vendorId - vendor ID
      productId - product ID
    • USBDeviceFilter

      public USBDeviceFilter(int vendorId, int productId, String serialNumber)
      Creates a new instance that matches the specified vendor ID, product ID and serial number.
      Parameters:
      vendorId - vendor ID
      productId - product ID
      serialNumber - serial number
  • Method Details

    • vendorId

      public Integer vendorId()
      Gets the USB vendor ID.
      Returns:
      vendor ID, or null if the vendor ID is not relevant for matching
    • setVendorId

      public void setVendorId(Integer vendorId)
      Sets the USB vendor ID.
      Parameters:
      vendorId - vendor ID, or null if the vendor ID is not relevant for matching
    • productId

      public Integer productId()
      Gets the USB product ID.
      Returns:
      product ID, or null if the product ID is not relevant for matching
    • setProductId

      public void setProductId(Integer productId)
      Sets the USB product ID.
      Parameters:
      productId - product ID, or null if the product ID is not relevant for matching
    • classCode

      public Integer classCode()
      Gets the USB device class code.
      Returns:
      class code, or null if the class code is not relevant for matching
    • setClassCode

      public void setClassCode(Integer classCode)
      Sets the USB device class code.
      Parameters:
      classCode - class code, or null if the class code is not relevant for matching
    • subclassCode

      public Integer subclassCode()
      Gets the USB device subclass code.
      Returns:
      subclass code, or null if the subclass code is not relevant for matching
    • setSubclassCode

      public void setSubclassCode(Integer subclassCode)
      Sets the USB device subclass code.
      Parameters:
      subclassCode - subclass code, or null if the subclass code is not relevant for matching
    • protocolCode

      public Integer protocolCode()
      Gets the USB device protocol code.
      Returns:
      protocol code, or null if the protocol code is not relevant for matching
    • setProtocolCode_

      public void setProtocolCode_(Integer protocolCode)
      Sets the USB device protocol code.
      Parameters:
      protocolCode - protocol code, or null if the protocol code is not relevant for matching
    • serialNumber

      public String serialNumber()
      Gets the device serial number.
      Returns:
      serial number, or null if the serial number is not relevant for matching
    • setSerialNumber

      public void setSerialNumber(String serialNumber)
      Sets the device serial number.
      Parameters:
      serialNumber - serial number, or null if the serial number is not relevant for matching
    • matches

      public boolean matches(USBDevice device)
      Tests if the specified USB device matches this filter.
      Parameters:
      device - USB device
      Returns:
      true if it matches, false otherwise
    • matchesAny

      public static boolean matchesAny(USBDevice device, List<USBDeviceFilter> filters)
      Test if the USB devices matches any of the filter conditions.
      Parameters:
      device - the USB device
      filters - a list of filter conditions
      Returns:
      true if it matches, false otherwise