INNER CODE UNIT · Java
from
scalecube/scalecube-services · services-api/src/main/java/io/scalecube/services/Address.java:30
public static Address from(String hostandport) {
if (hostandport == null || hostandport.isEmpty()) {
throw new IllegalArgumentException("host-and-port string must be present");
}
Matcher matcher = ADDRESS_FORMAT.matcher(hostandport);
if (!matcher.find()) {
throw new IllegalArgumentException("can't parse host-and-port string from: " + hostandport);
}
String host = matcher.group(1);
if (host == null || host.isEmpty()) {
throw new IllegalArgumentException("can't parse host from: " + hostandport);
}
int port;
try {
port = Integer.parseInt(matcher.group(2));