public Endpoint withPort(int port) {
        validatePort("port", port);

        if (this.port == port || isDomainSocket()) {
            return this;
        }

        return new Endpoint(type, host, ipAddr, port, weight, attributes);
    }
Returns a new host endpoint with the specified port number.

@param port the new port number
@return the new endpoint with the specified port number if this endpoint does not have a port or
        it has a different port number than what's specified.
        {@code this} if this endpoint has the same port number with the specified one.
core/src/main/java/com/linecorp/armeria/client/Endpoint.java