/**
 * Copyright 2016 Palantir Technologies
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.palantir.nexus.db.sql;

import java.util.StringTokenizer;

// TODO: This code was copied from papaya's TextUtils class, which will be moved to an internal product.
// If this project is also moved, then the duplication should be fixed.
public class TextUtils {
    private TextUtils() {
        // Utility class
    }

    /**
     *  Makes a list of n copies of the given string, separated by the given delimiter.
     */
    public static String makeStringList(String str, String delimiter, int count) {
        if (count == 0) {
            return "";
        }
        StringBuilder buf = new StringBuilder(str.length() * count + delimiter.length() * (count - 1));

        for (int i = 0; i < count - 1; i++) {
            buf.append(str);
            buf.append(delimiter);
        }
        buf.append(str);

        return buf.toString();
    }

    public static String removeAllWhitespace(String text) {
        return replaceAllWhitespace(text, "");
    }

    private static String replaceAllWhitespace(String text, String newSeparator) {
        StringBuilder sb = new StringBuilder();
        StringTokenizer st = new StringTokenizer(text);

        if (st.hasMoreTokens()) {
            sb.append(st.nextToken());
        }
        while (st.hasMoreTokens()) {
            sb.append(newSeparator);
            sb.append(st.nextToken());
        }

        return sb.toString();
    }
}

@@ -629,33 +629,44 @@
 ort 
-java.util.StringTokenizer
+org.apache.commons.lang3.StringUtils
 ;%0A%0A/
@@ -848,16 +848,22 @@
 %0Apublic 
+final 
 class Te
@@ -1129,891 +1129,181 @@
     
-if (count == 0) %7B%0A            return %22%22;%0A        %7D%0A        StringBuilder buf = new StringBuilder(str.length() * count + delimiter.length() * (count - 1));%0A%0A        for (int i = 0; i %3C count - 1; i++) %7B%0A            buf.append(str);%0A            buf.append(delimiter);%0A        %7D%0A        buf.append(str);%0A%0A        return buf.toString();%0A    %7D%0A%0A    public static String removeAllWhitespace(String text) %7B%0A        return replaceAllWhitespace(text, %22%22);%0A    %7D%0A%0A    private static String replaceAllWhitespace(String text, String newSeparator) %7B%0A        StringBuilder sb = new StringBuilder();%0A        StringTokenizer st = new StringTokenizer(text);%0A%0A        if (st.hasMoreTokens()) %7B%0A            sb.append(st.nextToken());%0A        %7D%0A        while (st.hasMoreTokens()) %7B%0A            sb.append(newSeparator);%0A            sb.append(st.nextToken()
+return StringUtils.repeat(str, delimiter, count);%0A    %7D%0A%0A    public static String removeAllWhitespace(String text) %7B%0A        return StringUtils.deleteWhitespace(text
 );%0A    
- 
-   %7D%0A%0A        return sb.toString();%0A    
 %7D
+%0A
 %0A%7D%0A

Use StringUtils in TextUtils