class SocketAddressParser {

    public static <T extends SocketAddress> T socketAddress( String settingValue,
            BiFunction<String,Integer,T> constructor )
    {
        if ( settingValue == null )
        {
            throw new IllegalArgumentException( "Cannot parse socket address from null" );
        }

        settingValue = settingValue.trim();

        T socketAddress;
        if ( (socketAddress = matchHostnamePort( settingValue, constructor )) != null )
        {
            return socketAddress;
        }

        throw new IllegalArgumentException( format(
                "Configured socket address must be in the format " +
                "\"hostname:port\". \"%s\" does not conform to this format", settingValue ) );
    }

}