public static String join()

in common/src/main/java/com/microsoft/alm/helpers/StringHelper.java [108:141]


    public static String join(final String separator, final String[] value, final int startIndex, final int count,
                              final Func<String, String> processor) {
        if (value == null)
            throw new IllegalArgumentException("value is null");
        if (startIndex < 0)
            throw new IllegalArgumentException("startIndex is less than 0");
        if (count < 0)
            throw new IllegalArgumentException("count is less than 0");
        if (startIndex + count > value.length)
            throw new IllegalArgumentException("startIndex + count is greater than the number of elements in value");

        // "If separator is null, an empty string ( String.Empty) is used instead."
        final String sep = ObjectExtensions.coalesce(separator, StringHelper.Empty);

        final StringBuilder result = new StringBuilder();

        if (value.length > 0 && count > 0) {
            String element = ObjectExtensions.coalesce(value[startIndex], StringHelper.Empty);
            if (processor != null) {
                element = processor.call(element);
            }
            result.append(element);
            for (int i = startIndex + 1; i < startIndex + count; i++) {
                result.append(sep);
                element = ObjectExtensions.coalesce(value[i], StringHelper.Empty);
                if (processor != null) {
                    element = processor.call(element);
                }
                result.append(element);
            }
        }

        return result.toString();
    }