com.qualcomm.robotcore.hardware

## Class HardwareMap.DeviceMapping<DEVICE_TYPE extends HardwareDevice>

- java.lang.Object
- - com.qualcomm.robotcore.hardware.HardwareMap.DeviceMapping<DEVICE_TYPE>

- Type Parameters:
    `DEVICE_TYPE` -
  All Implemented Interfaces:
    java.lang.Iterable<DEVICE_TYPE>
  Enclosing class:
    HardwareMap

      public class HardwareMap.DeviceMapping<DEVICE_TYPE extends HardwareDevice>
      extends java.lang.Object
      implements java.lang.Iterable<DEVICE_TYPE>

  A DeviceMapping contains a subcollection of the devices registered in a `HardwareMap` comprised of all the devices of a particular device type
  See Also:
    `get(String)`, `get(String)`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DeviceMapping(java.lang.Class<DEVICE_TYPE> deviceTypeClass)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DEVICE_TYPE` | `cast(java.lang.Object obj)` A small utility that assists in keeping the Java generics type system happy
    `boolean` | `contains(java.lang.String deviceName)` Returns whether a device of the indicated name is contained within this mapping
    `java.util.Set<java.util.Map.Entry<java.lang.String,DEVICE_TYPE>>` | `entrySet()` Returns a collection of all the (name, device) pairs in this DeviceMapping.
    `DEVICE_TYPE` | `get(java.lang.String deviceName)`
    `java.lang.Class<DEVICE_TYPE>` | `getDeviceTypeClass()` Returns the runtime device type for this mapping
    `protected void` | `internalPut(SerialNumber serialNumber, java.lang.String deviceName, DEVICE_TYPE device)`
    `java.util.Iterator<DEVICE_TYPE>` | `iterator()` Returns an iterator over all the devices in this DeviceMapping.
    `void` | `put(SerialNumber serialNumber, java.lang.String deviceName, DEVICE_TYPE device)` (Advanced) Registers a new device in this DeviceMapping under the indicated name.
    `void` | `put(java.lang.String deviceName, DEVICE_TYPE device)` Registers a new device in this DeviceMapping under the indicated name.
    `void` | `putLocal(java.lang.String deviceName, DEVICE_TYPE device)`
    `boolean` | `remove(SerialNumber serialNumber, java.lang.String deviceName)` (Advanced) Removes the device with the indicated name (if any) from this DeviceMapping.
    `boolean` | `remove(java.lang.String deviceName)` (Advanced) Removes the device with the indicated name (if any) from this DeviceMapping.
    `int` | `size()` Returns the number of devices currently in this DeviceMapping

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

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

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### DeviceMapping

          public DeviceMapping(java.lang.Class<DEVICE_TYPE> deviceTypeClass)

  - ### Method Detail

    - #### getDeviceTypeClass

          public java.lang.Class<DEVICE_TYPE> getDeviceTypeClass()

      Returns the runtime device type for this mapping

    - #### cast

          public DEVICE_TYPE cast(java.lang.Object obj)

      A small utility that assists in keeping the Java generics type system happy

    - #### get

          public DEVICE_TYPE get(java.lang.String deviceName)

    - #### put

          public void put(java.lang.String deviceName,
                          DEVICE_TYPE device)

      Registers a new device in this DeviceMapping under the indicated name. Any existing device with this name in this DeviceMapping is removed. The new device is also added to the overall collection in the overall map itself. Note that this method is normally called only by code in the SDK itself, not by user code.
      Parameters:
        `deviceName` - the name by which the new device is to be known (case sensitive)
        `device` - the new device to be named
      See Also:
        `HardwareMap.put(String, HardwareDevice)`

    - #### put

          public void put(SerialNumber serialNumber,
                          java.lang.String deviceName,
                          DEVICE_TYPE device)

      (Advanced) Registers a new device in this DeviceMapping under the indicated name. Any existing device with this name in this DeviceMapping is removed. The new device is also added to the overall collection in the overall map itself. Note that this method is normally called only by code in the SDK itself, not by user code.
      Parameters:
        `serialNumber` - the serial number of the device
        `deviceName` - the name by which the new device is to be known (case sensitive)
        `device` - the new device to be named
      See Also:
        `HardwareMap.put(String, HardwareDevice)`

    - #### internalPut

          protected void internalPut(SerialNumber serialNumber,
                                     java.lang.String deviceName,
                                     DEVICE_TYPE device)

    - #### putLocal

          public void putLocal(java.lang.String deviceName,
                               DEVICE_TYPE device)

    - #### contains

          public boolean contains(java.lang.String deviceName)

      Returns whether a device of the indicated name is contained within this mapping
      Parameters:
        `deviceName` - the name sought
      Returns:
        whether a device of the indicated name is contained within this mapping

    - #### remove

          public boolean remove(java.lang.String deviceName)

      (Advanced) Removes the device with the indicated name (if any) from this DeviceMapping. The device is also removed under that name in the overall map itself. Note that this method is normally called only by code in the SDK itself, not by user code.
      Parameters:
        `deviceName` - the name of the device to remove.
      Returns:
        whether any modifications were made to this DeviceMapping
      See Also:
        `HardwareMap.remove(java.lang.String, com.qualcomm.robotcore.hardware.HardwareDevice)`

    - #### remove

          public boolean remove(SerialNumber serialNumber,
                                java.lang.String deviceName)

      (Advanced) Removes the device with the indicated name (if any) from this DeviceMapping. The device is also removed under that name in the overall map itself. Note that this method is normally called only by code in the SDK itself, not by user code.
      Parameters:
        `serialNumber` - (optional) the serial number of the device to remove
        `deviceName` - the name of the device to remove.
      Returns:
        whether any modifications were made to this DeviceMapping
      See Also:
        `HardwareMap.remove(java.lang.String, com.qualcomm.robotcore.hardware.HardwareDevice)`

    - #### iterator

          public java.util.Iterator<DEVICE_TYPE> iterator()

      Returns an iterator over all the devices in this DeviceMapping.
      Specified by:
        `iterator` in interface `java.lang.Iterable<DEVICE_TYPE extends HardwareDevice>`
      Returns:
        an iterator over all the devices in this DeviceMapping.

    - #### entrySet

          public java.util.Set<java.util.Map.Entry<java.lang.String,DEVICE_TYPE>> entrySet()

      Returns a collection of all the (name, device) pairs in this DeviceMapping.
      Returns:
        a collection of all the (name, device) pairs in this DeviceMapping.

    - #### size

          public int size()

      Returns the number of devices currently in this DeviceMapping
      Returns:
        the number of devices currently in this DeviceMapping