All Downloads are FREE. Search and download functionalities are using the official Maven repository.

oshi.hardware.platform.unix.aix.AixUsbDevice Maven / Gradle / Ivy

/**
 * MIT License
 *
 * Copyright (c) 2010 - 2021 The OSHI Project Contributors: https://github.com/oshi/oshi/graphs/contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package oshi.hardware.platform.unix.aix;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;

import oshi.annotation.concurrent.Immutable;
import oshi.hardware.UsbDevice;
import oshi.hardware.common.AbstractUsbDevice;
import oshi.util.Constants;
import oshi.util.ParseUtil;

/**
 * AIX Usb Device
 */
@Immutable
public class AixUsbDevice extends AbstractUsbDevice {

    public AixUsbDevice(String name, String vendor, String vendorId, String productId, String serialNumber,
            String uniqueDeviceId, List connectedDevices) {
        super(name, vendor, vendorId, productId, serialNumber, uniqueDeviceId, connectedDevices);
    }

    /**
     * Instantiates a list of {@link oshi.hardware.UsbDevice} objects, representing
     * devices connected via a usb port (including internal devices).
     * 

* If the value of {@code tree} is true, the top level devices returned from * this method are the USB Controllers; connected hubs and devices in its device * tree share that controller's bandwidth. If the value of {@code tree} is * false, USB devices (not controllers) are listed in a single flat list. * * @param tree * If true, returns a list of controllers, which requires recursive * iteration of connected devices. If false, returns a flat list of * devices excluding controllers. * @param lscfg * A memoized lscfg list * @return a list of {@link oshi.hardware.UsbDevice} objects. */ public static List getUsbDevices(boolean tree, Supplier> lscfg) { List deviceList = new ArrayList<>(); for (String line : lscfg.get()) { String s = line.trim(); if (s.startsWith("usb")) { String[] split = ParseUtil.whitespaces.split(s, 3); if (split.length == 3) { deviceList.add(new AixUsbDevice(split[2], Constants.UNKNOWN, Constants.UNKNOWN, Constants.UNKNOWN, Constants.UNKNOWN, split[0], Collections.emptyList())); } } } if (tree) { return Arrays.asList(new AixUsbDevice("USB Controller", "", "0000", "0000", "", "", deviceList)); } return deviceList; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy