// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java
//  public static Predicate<UsbDevice> deviceHasVendorIdAndProductId(final short vendorId, final short productId) {
//      return new Predicate<UsbDevice>() {
// public boolean test(UsbDevice device) {
//        return vendorAndProductIdsMatch(vendorId, productId, device);
//    }
//      };
//  }
// 
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java
// public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) {
// 	return new UsbDeviceFinder(shouldIncludeDevice);
// }
// 
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java
// public class UsbDeviceFinder extends UsbTopologyExplorer {
// 
// 	public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) {
// 		super(shouldIncludeDevice);
// 	}
// 	
// 	public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) {
// 		return new UsbDeviceFinder(shouldIncludeDevice);
// 	}
// 
// 	private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>();
// 	
// 	@Override
// 	public void visit(UsbDevice usbDevice) {
// 		devices.add(eased(usbDevice));
// 	}
// 
// 	public List<EasyUsbDevice> getDevices() {
// 		return Collections.unmodifiableList(devices);
// 	}
// }


import static com.iamcontent.io.usb.UsbDevicePredicates.deviceHasVendorIdAndProductId;
import static com.iamcontent.io.usb.topology.UsbDeviceFinder.usbDeviceFinder;
import java.util.List;
import java.util.function.Predicate;
import javax.usb.UsbDevice;
import javax.usb.UsbHostManager;
import javax.usb.UsbHub;
import javax.usb.UsbServices;
import com.iamcontent.io.usb.topology.UsbDeviceFinder;

/**
  IAmContent Public Libraries.
  Copyright (C) 2015-2021 Greg Elderfield
  @author Greg Elderfield, support@jarchitect.co.uk
 
  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU General Public License as published by the Free Software Foundation; either version 2 of 
  the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along with this program;
  if not, write to the Free Software Foundation, Inc., 
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package com.iamcontent.io.usb;





/**
 * USB utility methods.
 * @author Greg Elderfield
 */
public class Usb {

    public static EasyUsbDevice device(short vendorId, short productId) {
        return first(devices(vendorId, productId));
    }

    public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) {
        return first(devices(shouldIncludeDevice));
    }

    public static List<EasyUsbDevice> devices(short vendorId, short productId) {

// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java
//  public static Predicate<UsbDevice> deviceHasVendorIdAndProductId(final short vendorId, final short productId) {
//      return new Predicate<UsbDevice>() {
// public boolean test(UsbDevice device) {
//        return vendorAndProductIdsMatch(vendorId, productId, device);
//    }
//      };
//  }
// 
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java
// public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) {
// 	return new UsbDeviceFinder(shouldIncludeDevice);
// }
// 
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java
// public class UsbDeviceFinder extends UsbTopologyExplorer {
// 
// 	public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) {
// 		super(shouldIncludeDevice);
// 	}
// 	
// 	public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) {
// 		return new UsbDeviceFinder(shouldIncludeDevice);
// 	}
// 
// 	private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>();
// 	
// 	@Override
// 	public void visit(UsbDevice usbDevice) {
// 		devices.add(eased(usbDevice));
// 	}
// 
// 	public List<EasyUsbDevice> getDevices() {
// 		return Collections.unmodifiableList(devices);
// 	}
// }


// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java
import static com.iamcontent.io.usb.UsbDevicePredicates.deviceHasVendorIdAndProductId;
import static com.iamcontent.io.usb.topology.UsbDeviceFinder.usbDeviceFinder;
import java.util.List;
import java.util.function.Predicate;
import javax.usb.UsbDevice;
import javax.usb.UsbHostManager;
import javax.usb.UsbHub;
import javax.usb.UsbServices;
import com.iamcontent.io.usb.topology.UsbDeviceFinder;

/**
  IAmContent Public Libraries.
  Copyright (C) 2015-2021 Greg Elderfield
  @author Greg Elderfield, support@jarchitect.co.uk
 
  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU General Public License as published by the Free Software Foundation; either version 2 of 
  the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along with this program;
  if not, write to the Free Software Foundation, Inc., 
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package com.iamcontent.io.usb;





/**
 * USB utility methods.
 * @author Greg Elderfield
 */
public class Usb {

    public static EasyUsbDevice device(short vendorId, short productId) {
        return first(devices(vendorId, productId));
    }

    public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) {
        return first(devices(shouldIncludeDevice));
    }

    public static List<EasyUsbDevice> devices(short vendorId, short productId) {

    	return devices(deviceHasVendorIdAndProductId(vendorId, productId));
