Package io.atomix.utils.net
Class Address
- java.lang.Object
-
- io.atomix.utils.net.Address
-
public final class Address extends Object
Representation of a network address.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAddress.TypeAddress type.
-
Constructor Summary
Constructors Constructor Description Address(String host, int port)Address(String host, int port, InetAddress address)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description InetAddressaddress()Returns the IP address.InetAddressaddress(boolean resolve)Returns the IP address.booleanequals(Object obj)static Addressfrom(int port)Returns an address for the local host and the given port.static Addressfrom(String address)Returns the address from the given host:port string.static Addressfrom(String host, int port)Returns an address for the given host/port.inthashCode()Stringhost()Returns the host name.static Addresslocal()Returns an address that binds to all interfaces.intport()Returns the port.InetSocketAddresssocketAddress()StringtoString()Address.Typetype()Returns the address type.
-
-
-
Constructor Detail
-
Address
public Address(String host, int port)
-
Address
public Address(String host, int port, InetAddress address)
-
-
Method Detail
-
local
public static Address local()
Returns an address that binds to all interfaces.- Returns:
- the address
-
from
public static Address from(String address)
Returns the address from the given host:port string.- Parameters:
address- the address string- Returns:
- the address
-
from
public static Address from(String host, int port)
Returns an address for the given host/port.- Parameters:
host- the host nameport- the port- Returns:
- a new address
-
from
public static Address from(int port)
Returns an address for the local host and the given port.- Parameters:
port- the port- Returns:
- a new address
-
host
public String host()
Returns the host name.- Returns:
- the host name
-
port
public int port()
Returns the port.- Returns:
- the port
-
address
public InetAddress address()
Returns the IP address.- Returns:
- the IP address
-
address
public InetAddress address(boolean resolve)
Returns the IP address.- Parameters:
resolve- whether to force resolve the hostname- Returns:
- the IP address
-
socketAddress
public InetSocketAddress socketAddress()
-
type
public Address.Type type()
Returns the address type.- Returns:
- the address type
-
-