public static SocketAddress createFrom(String value) {
    if (value.startsWith(UNIX_DOMAIN_SOCKET_PREFIX)) {
      // Unix Domain Socket address.
      // Create the underlying file for the Unix Domain Socket.
      String filePath = value.substring(UNIX_DOMAIN_SOCKET_PREFIX.length());
      File file = new File(filePath);
      if (!file.isAbsolute()) {
        throw new IllegalArgumentException("File path must be absolute: " + filePath);
      }
      try {
        if (file.createNewFile()) {
          // If this application created the file, delete it when the application exits.
          file.deleteOnExit();
        }
      } catch (IOException ex) {
        throw new RuntimeException(ex);
      }
      // Create the SocketAddress referencing the file.
      return new DomainSocketAddress(file);
    } else {
      // Standard TCP/IP address.
      HostAndPort hostAndPort = HostAndPort.fromString(value);
      checkArgument(
          hostAndPort.hasPort(),
          "Address must be a unix:// path or be in the form host:port. Got: %s",
          value);
      return new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort());
    }
  }
@Test
  public void testHostPortSocket() {
    SocketAddress socketAddress = SocketAddressFactory.createFrom("localhost:123");
    assertThat(socketAddress, Matchers.instanceOf(InetSocketAddress.class));
    assertEquals("localhost", ((InetSocketAddress) socketAddress).getHostString());
    assertEquals(123, ((InetSocketAddress) socketAddress).getPort());
  }