com.h3c.util.ip

## Class MacUtils

- java.lang.Object
- - com.h3c.util.ip.MacUtils

-     public final class MacUtils
      extends Object

  Useful utility methods for manipulating `MAC addresses`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static String` | `COUNT_GE_ONE` Exception Message: count must be greater than 1

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static List<MacAddress>` | `getRandomMacs(MacRange range, int count)` Returns a list of randomly generated MAC addresses.
    `static List<MacAddress>` | `getRandomMacs(String spec, int count)` Returns a list of randomly generated MAC addresses.
    `static MacAddress` | `getRepeatedByteMacAddress(int seed)` Returns a MAC address where all the bytes are set to the specified seed value.

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

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

- - ### Field Detail

    - #### COUNT_GE_ONE

          protected static final String COUNT_GE_ONE

      Exception Message: count must be greater than 1
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getRepeatedByteMacAddress

          public static MacAddress getRepeatedByteMacAddress(int seed)

      Returns a MAC address where all the bytes are set to the specified seed value. For example:

           MacAddress mac = MacUtils.getRepeatedByteMacAddress(249);

      will return the MAC address `F9:F9:F9:F9:F9:F9`
      Parameters:
        `seed` - the seed value
      Returns:
        the MAC address
      Throws:
        `IllegalArgumentException` - if seed is not in the range 0..255

    - #### getRandomMacs

          public static List<MacAddress> getRandomMacs(String spec,
                                       int count)

      Returns a list of randomly generated MAC addresses. See `MacRange` for a definition of the range specification. Note that addresses may be repeated in the list.
      Parameters:
        `spec` - a string defining the set of MAC addresses from which to draw the random samples
        `count` - the number of MAC addresses to return in the list
      Returns:
        a list of randomly generated MAC addresses
      Throws:
        `IllegalArgumentException` - if count is less than 1 or if the spec is ill-formed
        `NullPointerException` - if spec is null

    - #### getRandomMacs

          public static List<MacAddress> getRandomMacs(MacRange range,
                                       int count)

      Returns a list of randomly generated MAC addresses. Note that addresses may be repeated in the list.
      Parameters:
        `range` - a MAC address range from which to draw the random samples
        `count` - the number of MAC addresses to return in the list
      Returns:
        a list of randomly generated MAC addresses
      Throws:
        `IllegalArgumentException` - if count is less than 1

Copyright © 2014. All Rights Reserved.