com.h3c.of.lib.dt

## Class VId

- java.lang.Object
- - com.h3c.util.cache.CacheableDataType
  - - com.h3c.util.ip.UnsignedId
    - - com.h3c.util.ip.UnsignedIntBasedId
      - - com.h3c.util.ip.U16Id
        - - com.h3c.of.lib.dt.VId

- All Implemented Interfaces:
    Serializable, Comparable<VId>

      public final class VId
      extends U16Id
      implements Comparable<VId>

  Represents a virtual identifier (unsigned 16-bit).

  Creating instances of `VId` is done via the static methods of the class, or by using the predefined constants `NONE` or `PRESENT`.

  Instances of this class are immutable, making them inherently threadsafe.

  This class overrides `UnsignedIntBasedId.equals(java.lang.Object)` and `UnsignedIntBasedId.hashCode()` so that instances play nicely with the Collection classes.

  This class implements the `Comparable` interface to ensure that a sorted list of virtual identifiers is presented in an intuitive order.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static VId` | `NONE` A special value denoting the absence of a virtual identifier.
    `static VId` | `PRESENT` A special value denoting the presence of a virtual identifier, without defining the specific value.

    - ### Fields inherited from class com.h3c.util.ip.U16Id

      `E_BYTES_BAD_LEN, LENGTH_IN_BYTES, MAX_VALUE`

    - ### Fields inherited from class com.h3c.util.ip.UnsignedIntBasedId

      `id`

    - ### Fields inherited from class com.h3c.util.ip.UnsignedId

      `E_BAD, E_NULL_BYTES, E_NULL_STR, E_OOR, MIN_VALUE`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(VId o)` Implements the Comparable interface, to return virtual identifiers in natural order.
    `static String` | `specialName(VId v)` Returns the logical name of the given identifier if it is a special value; null otherwise.
    `VId` | `to12Bits()` Returns the virtual identifier equivalent to this one with the top 4 bits zeroed out.
    `String` | `toString()` Returns a string representation of this id.
    `static VId` | `valueOf(byte[] bytes)` Returns an object that represents the virtual identifier defined by the specified byte array.
    `static VId` | `valueOf(int vid)` Returns an object that represents the virtual identifier defined by the specified integer.
    `static VId` | `valueOf(String vidStr)` Returns an object that represents the virtual identifier defined by the specified string.

    - ### Methods inherited from class com.h3c.util.ip.U16Id

      `rangeCheck, toByteArray`

    - ### Methods inherited from class com.h3c.util.ip.UnsignedIntBasedId

      `equals, hashCode, toInt`

    - ### Methods inherited from class com.h3c.util.ip.UnsignedId

      `parseIntStr, parseLongStr`

    - ### Methods inherited from class com.h3c.util.cache.CacheableDataType

      `getRefQ, keyFromBytes`

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

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

- - ### Field Detail

    - #### NONE

          public static final VId NONE

      A special value denoting the absence of a virtual identifier.

    - #### PRESENT

          public static final VId PRESENT

      A special value denoting the presence of a virtual identifier, without defining the specific value.

  - ### Method Detail

    - #### to12Bits

          public VId to12Bits()

      Returns the virtual identifier equivalent to this one with the top 4 bits zeroed out. In other words, applies the mask `0x0fff`.
      Returns:
        the id constrained to tbe bottom 12 bits

    - #### compareTo

          public int compareTo(VId o)

      Implements the Comparable interface, to return virtual identifiers in natural order.
      Specified by:
        `compareTo` in interface `Comparable<VId>`
      Parameters:
        `o` - the other identifier
      Returns:
        an integer value indicating relative ordering
      See Also:
        `Comparable.compareTo(T)`

    - #### toString

          public String toString()

      Description copied from class: `UnsignedIntBasedId`
      Returns a string representation of this id.
      Overrides:
        `toString` in class `UnsignedIntBasedId`
      Returns:
        the id, as a string

    - #### valueOf

          public static VId valueOf(int vid)

      Returns an object that represents the virtual identifier defined by the specified integer.
      Parameters:
        `vid` - the virtual id number
      Returns:
        a VId instance
      Throws:
        `IllegalArgumentException` - if the id number is invalid

    - #### valueOf

          public static VId valueOf(String vidStr)

      Returns an object that represents the virtual identifier defined by the specified string. The string is parsed as a base-10 integer.
      Parameters:
        `vidStr` - the virtual id number as a string
      Returns:
        a VId instance
      Throws:
        `IllegalArgumentException` - if the string is invalid
        `NullPointerException` - if the string is null

    - #### valueOf

          public static VId valueOf(byte[] bytes)

      Returns an object that represents the virtual identifier defined by the specified byte array. The array is expected to be `U16Id.LENGTH_IN_BYTES` bytes long.
      Parameters:
        `bytes` - the encoded id
      Returns:
        a VId instance
      Throws:
        `NullPointerException` - if the byte array is null
        `IllegalArgumentException` - if the byte array is not 2 bytes long

    - #### specialName

          public static String specialName(VId v)

      Returns the logical name of the given identifier if it is a special value; null otherwise.
      Parameters:
        `v` - the value
      Returns:
        its logical name

Copyright © 2014. All Rights Reserved.