class HostnamePort {

    public HostnamePort( String hostnamePort ) throws IllegalArgumentException
    {
        Objects.requireNonNull( hostnamePort );

        String[] parts = splitHostAndPort( hostnamePort );
        if ( parts.length == 1 )
        {
            host = StringUtils.defaultIfBlank( parts[0], null );
            ports = new int[]{0, 0};
        }
        else if ( parts.length == 2 )
        {
            host = StringUtils.defaultIfBlank( parts[0], null );

            String[] portStrings = parts[1].split( "-" );
            ports = new int[2];

            if ( portStrings.length == 1 )
            {
                ports[0] = ports[1] = Integer.parseInt( portStrings[0] );
            }
            else if ( portStrings.length == 2 )
            {
                ports[0] = Integer.parseInt( portStrings[0] );
                ports[1] = Integer.parseInt( portStrings[1] );
            }
            else
            {
                throw new IllegalArgumentException( format( "Cannot have more than two port ranges: %s",
                        hostnamePort ) );
            }
        }
        else
        {
            throw new IllegalArgumentException( hostnamePort );
        }
    }

    public  HostnamePort( String hostnamePort );
    public  HostnamePort( String host, int port );
    public  HostnamePort( String host, int portFrom, int portTo );

}