com.h3c.util.ip

## Class IpDnsPair

- java.lang.Object
- - com.h3c.util.cache.CacheableDataType
  - - com.h3c.util.ip.IpDnsPair

- All Implemented Interfaces:
    Serializable, Comparable<IpDnsPair>

      public final class IpDnsPair
      extends CacheableDataType
      implements Comparable<IpDnsPair>

  Links together an `IpAddress` and a `DnsName` as a pair.

  All constructors for this class are private. Creating instances of `IpDnsPair` is done via the static `valueOf(com.h3c.util.ip.IpAddress, com.h3c.util.ip.DnsName)` methods on the class.

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

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

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

  See Also:
    Serialized Form

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(IpDnsPair o)` Delegates our comparable to the IpAddress implementation.
    `boolean` | `equals(Object o)`
    `DnsName` | `getDns()` Returns the DNS name.
    `IpAddress` | `getIp()` Returns the IP address.
    `int` | `hashCode()`
    `boolean` | `hasUnresolvableDnsName()` Returns true if the DNS name stored is an "Unresolvable" instance.
    `String` | `toString()`
    `static IpDnsPair` | `valueOf(IpAddress ip)` Returns an `IpDnsPair` object that represents the specified `IpAddress` and the "unresolvable" `DnsName` paired together.
    `static IpDnsPair` | `valueOf(IpAddress ip, DnsName dns)` Returns an `IpDnsPair` object that represents the specified `IpAddress` and `DnsName` paired together.
    `static IpDnsPair` | `valueOf(String ip)` Calls `valueOf(IpAddress)` after converting the string parameter to an IpAddress instance.
    `static IpDnsPair` | `valueOf(String ip, String dns)` Calls `valueOf(IpAddress,DnsName)` after converting the string parameters to their respective data-types.

    - ### 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`

- - ### Method Detail

    - #### getIp

          public IpAddress getIp()

      Returns the IP address.
      Returns:
        the IP address

    - #### getDns

          public DnsName getDns()

      Returns the DNS name.
      Returns:
        the DNS name

    - #### hasUnresolvableDnsName

          public boolean hasUnresolvableDnsName()

      Returns true if the DNS name stored is an "Unresolvable" instance.
      Returns:
        true if the DNS name is "Unresolvable"

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### compareTo

          public int compareTo(IpDnsPair o)

      Delegates our comparable to the IpAddress implementation.
      Specified by:
        `compareTo` in interface `Comparable<IpDnsPair>`
      Parameters:
        `o` - the other pair
      Returns:
        a result indicating our relative ordering

    - #### valueOf

          public static IpDnsPair valueOf(IpAddress ip,
                          DnsName dns)

      Returns an `IpDnsPair` object that represents the specified `IpAddress` and `DnsName` paired together.
      Parameters:
        `ip` - the ip address
        `dns` - the dns name
      Returns:
        the IP / DNS name pair
      Throws:
        `NullPointerException` - if either parameter is null

    - #### valueOf

          public static IpDnsPair valueOf(String ip,
                          String dns)

      Calls `valueOf(IpAddress,DnsName)` after converting the string parameters to their respective data-types.
      Parameters:
        `ip` - a string representation of an IP address
        `dns` - a string representation of a DNS name
      Returns:
        the IP / DNS name pair
      Throws:
        `NullPointerException` - if either parameter is null

    - #### valueOf

          public static IpDnsPair valueOf(IpAddress ip)

      Returns an `IpDnsPair` object that represents the specified `IpAddress` and the "unresolvable" `DnsName` paired together. This convenience method is equivalent to invoking:

             IpDnsPair p = IpDnsPair.valueOf(ip, DnsName.getUnresolvableInstance());

      Parameters:
        `ip` - the ip address
      Returns:
        the IP / Unresolvable DNS name pair
      Throws:
        `NullPointerException` - if the parameter is null

    - #### valueOf

          public static IpDnsPair valueOf(String ip)

      Calls `valueOf(IpAddress)` after converting the string parameter to an IpAddress instance.
      Parameters:
        `ip` - a string representation of an IP address
      Returns:
        the IP / Unresolvable DNS name pair
      Throws:
        `NullPointerException` - if the parameter is null

Copyright © 2014. All Rights Reserved.