P4ServerName { @Nullable public static P4ServerName forPort(@Nullable final String portText) { if (portText == null) { return null; } String protocolText = null; String port = portText.trim(); int splitter = portText.indexOf(PROTOCOL_SEP); if (splitter >= portText.length() - PROTOCOL_SEP.length()) { port = ":"; } else if (splitter >= 0) { protocolText = portText.substring(0, splitter); port = portText.substring(splitter + PROTOCOL_SEP.length()); } else { splitter = portText.indexOf(':'); if (splitter > 0) { int splitter2 = portText.indexOf(':', splitter + 1); if (splitter2 > 0) { protocolText = portText.substring(0, splitter); port = portText.substring(splitter + 1); } } } if (port.indexOf(':') <= 0) { port = "localhost:" + port; } return new P4ServerName(port, parseProtocol(protocolText)); } private  P4ServerName(
            @NotNull String server,
            @NotNull IServerAddress.Protocol protocol); @Nullable static P4ServerName forPort(@Nullable final String portText); @NotNull static P4ServerName forPortNotNull(@Nullable final String portText); @NotNull IServerAddress.Protocol getServerProtocol(); @NotNull String getProtocolName(); @NotNull String getServerPort(); @NotNull String getFullPort(); @NotNull String getDisplayName(); @NotNull String getUrl(); boolean isSecure(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test void forPort_null() { assertThat(P4ServerName.forPort(null), nullValue()); }
@Test void equals1() { P4ServerName name1 = P4ServerName.forPort("tcp:host:1234"); P4ServerName name2 = P4ServerName.forPort("host:1234"); assertThat(name1, is(name2)); }