Package com.norconex.commons.lang.net

# Class Host

java.lang.Object
com.norconex.commons.lang.net.Host

All Implemented Interfaces:
  `Serializable`

public final class Host extends Object implements Serializable
Holds a host name and port.

Since:
  2.0.0
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Host(String name, int port)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object o)`
  `String`
  `getName()`
  `int`
  `getPort()`
  `int`
  `hashCode()`
  `boolean`
  `isSet()`
  `InetSocketAddress`
  `toInetSocketAddress()`
  Converts this host to an `InetSocketAddress` if the name is set, otherwise returns `null`.
  `String`
  `toString()`
  `Host`
  `withName(String name)`
  `Host`
  `withPort(int port)`

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

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

- ## Constructor Details

  - ### Host

    public Host(String name, int port)

- ## Method Details

  - ### getName

    public String getName()

  - ### getPort

    public int getPort()

  - ### isSet

    public boolean isSet()

  - ### withName

    public Host withName(String name)

  - ### withPort

    public Host withPort(int port)

  - ### toInetSocketAddress

    public InetSocketAddress toInetSocketAddress()
    Converts this host to an `InetSocketAddress` if the name is set, otherwise returns `null`. The port must be greater or equal to zero.
    Returns:
      socket address or `null`

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