public static String rightPad(String str, int size, String padStr) {
        if (str == null) {
            return null;
        }
        if (isEmpty(padStr)) {
            padStr = " ";
        }
        int padLen = padStr.length();
        int strLen = str.length();
        int pads = size - strLen;
        if (pads <= 0) {
            return str; // returns original String when possible
        }
        if (padLen == 1 && pads <= PAD_LIMIT) {
            return rightPad(str, size, padStr.charAt(0));
        }

        if (pads == padLen) {
            return str.concat(padStr);
        } else if (pads < padLen) {
            return str.concat(padStr.substring(0, pads));
        } else {
            char[] padding = new char[pads];
            char[] padChars = padStr.toCharArray();
            for (int i = 0; i < pads; i++) {
                padding[i] = padChars[i % padLen];
            }
            return str.concat(new String(padding));
        }
    }
<p>Right pad a String with a specified String.</p>

<p>The String is padded to the size of {@code size}.</p>

<pre>
StringUtils.rightPad(null, *, *)      = null
StringUtils.rightPad("", 3, "z")      = "zzz"
StringUtils.rightPad("bat", 3, "yz")  = "bat"
StringUtils.rightPad("bat", 5, "yz")  = "batyz"
StringUtils.rightPad("bat", 8, "yz")  = "batyzyzy"
StringUtils.rightPad("bat", 1, "yz")  = "bat"
StringUtils.rightPad("bat", -1, "yz") = "bat"
StringUtils.rightPad("bat", 5, null)  = "bat  "
StringUtils.rightPad("bat", 5, "")    = "bat  "
</pre>

@param str  the String to pad out, may be null
@param size  the size to pad to
@param padStr  the String to pad with, null or empty treated as single space
@return right padded String or original String if no padding is necessary,
 {@code null} if null String input
android/android_framework/base/src/main/java/lang3/StringUtils.java