/// <summary>
        /// Conditionally adds a path segment.
        /// </summary>
        /// <param name="builder">The <see cref="FluentUriBuilder"/>.</param>
        /// <param name="segment">The new segment to add.</param>
        /// <param name="condition">The condition to check. The param will only be added if true.</param>
        /// <param name="encode">True to UrlEncode the value, false otherwise.</param>
        /// <returns>A new instance of <see cref="FluentUriBuilder"/> with the added segment.</returns>
        public static FluentUriBuilder WithSegmentIf(this FluentUriBuilder builder, string segment, bool condition, bool encode = true)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (!condition)
            {
                return(builder);
            }

            return(builder.WithSegment(segment, encode));
        }
        /// <summary>
        /// Adds a path segment. Calls <see cref="object.ToString"/> on the <paramref name="segment"/>.
        /// </summary>
        /// <param name="builder">The <see cref="FluentUriBuilder"/>.</param>
        /// <param name="segment">The new segment to add.</param>
        /// <param name="encode">True to UrlEncode the value, false otherwise.</param>
        /// <returns>A new instance of <see cref="FluentUriBuilder"/> with the added segment.</returns>
        public static FluentUriBuilder WithSegment(this FluentUriBuilder builder, object segment, bool encode = true)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (segment == null)
            {
                return(builder);
            }

            return(builder.WithSegment(segment.ToString(), encode));
        }