@Test void capitalize() { Assertions.assertEquals(".", StringUtils.capitalize(".")); Assertions.assertEquals("Test", StringUtils.capitalize("test")); Assertions.assertEquals(StringUtils.EMPTY, StringUtils.capitalize(StringUtils.EMPTY)); }
public static String capitalize(String text) { int strLen; if (text == null || (strLen = text.length()) == 0) { return text; } int firstCodePoint = text.codePointAt(0); int newCodePoint = Character.toTitleCase(firstCodePoint); if (firstCodePoint == newCodePoint) { return text; } int[] newCodePoints = new int[strLen]; int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; for (int inOffset = Character.charCount(firstCodePoint); inOffset < strLen; ) { int codePoint = text.codePointAt(inOffset); newCodePoints[outOffset++] = codePoint; inOffset += Character.charCount(codePoint); } return new String(newCodePoints, 0, outOffset); }
StringUtils { public static String capitalize(String text) { int strLen; if (text == null || (strLen = text.length()) == 0) { return text; } int firstCodePoint = text.codePointAt(0); int newCodePoint = Character.toTitleCase(firstCodePoint); if (firstCodePoint == newCodePoint) { return text; } int[] newCodePoints = new int[strLen]; int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; for (int inOffset = Character.charCount(firstCodePoint); inOffset < strLen; ) { int codePoint = text.codePointAt(inOffset); newCodePoints[outOffset++] = codePoint; inOffset += Character.charCount(codePoint); } return new String(newCodePoints, 0, outOffset); } }
StringUtils { public static String capitalize(String text) { int strLen; if (text == null || (strLen = text.length()) == 0) { return text; } int firstCodePoint = text.codePointAt(0); int newCodePoint = Character.toTitleCase(firstCodePoint); if (firstCodePoint == newCodePoint) { return text; } int[] newCodePoints = new int[strLen]; int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; for (int inOffset = Character.charCount(firstCodePoint); inOffset < strLen; ) { int codePoint = text.codePointAt(inOffset); newCodePoints[outOffset++] = codePoint; inOffset += Character.charCount(codePoint); } return new String(newCodePoints, 0, outOffset); } private  StringUtils(); }
StringUtils { public static String capitalize(String text) { int strLen; if (text == null || (strLen = text.length()) == 0) { return text; } int firstCodePoint = text.codePointAt(0); int newCodePoint = Character.toTitleCase(firstCodePoint); if (firstCodePoint == newCodePoint) { return text; } int[] newCodePoints = new int[strLen]; int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; for (int inOffset = Character.charCount(firstCodePoint); inOffset < strLen; ) { int codePoint = text.codePointAt(inOffset); newCodePoints[outOffset++] = codePoint; inOffset += Character.charCount(codePoint); } return new String(newCodePoints, 0, outOffset); } private  StringUtils(); static String[] splitFirst(String text, String delimiter); static String[] split(String text, String delimiter); static int lastIndexOfBefore(String text, String element, int occurrences); static int lastIndexOf(String text, String element, int toIndex); static String replace(String text, String searchString, String replacement); static String replaceFirst(String text, String pattern, String replacement); static String replaceFirst(String text, String pattern, String replacement, int start); static String replaceRespectively(String text, String pattern, String... values); static String replaceRespectivelyAndSoftly(String text, String pattern, String... values); static String capitalize(String text); static boolean startsWith(String text, Predicate<char[]> filter); static String trimStart(String text); static String trimEnd(String text); static String extractParagraph(String str); static String buildSpace(int spaces); static String repeated(int repetitions, String... elements); static int countOccurrences(String text, String element); static boolean containsCharacter(String text, char... characters); static boolean containsSpecialCharacters(String text); static boolean containsOtherCharacters(String text, char[]... characters); static String join(String... strings); static String toString(@Nullable Object object); static boolean isNumber(String str); static String isEmpty(String text, String exceptionMessage); static boolean isEmpty(String text); }
StringUtils { public static String capitalize(String text) { int strLen; if (text == null || (strLen = text.length()) == 0) { return text; } int firstCodePoint = text.codePointAt(0); int newCodePoint = Character.toTitleCase(firstCodePoint); if (firstCodePoint == newCodePoint) { return text; } int[] newCodePoints = new int[strLen]; int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; for (int inOffset = Character.charCount(firstCodePoint); inOffset < strLen; ) { int codePoint = text.codePointAt(inOffset); newCodePoints[outOffset++] = codePoint; inOffset += Character.charCount(codePoint); } return new String(newCodePoints, 0, outOffset); } private  StringUtils(); static String[] splitFirst(String text, String delimiter); static String[] split(String text, String delimiter); static int lastIndexOfBefore(String text, String element, int occurrences); static int lastIndexOf(String text, String element, int toIndex); static String replace(String text, String searchString, String replacement); static String replaceFirst(String text, String pattern, String replacement); static String replaceFirst(String text, String pattern, String replacement, int start); static String replaceRespectively(String text, String pattern, String... values); static String replaceRespectivelyAndSoftly(String text, String pattern, String... values); static String capitalize(String text); static boolean startsWith(String text, Predicate<char[]> filter); static String trimStart(String text); static String trimEnd(String text); static String extractParagraph(String str); static String buildSpace(int spaces); static String repeated(int repetitions, String... elements); static int countOccurrences(String text, String element); static boolean containsCharacter(String text, char... characters); static boolean containsSpecialCharacters(String text); static boolean containsOtherCharacters(String text, char[]... characters); static String join(String... strings); static String toString(@Nullable Object object); static boolean isNumber(String str); static String isEmpty(String text, String exceptionMessage); static boolean isEmpty(String text); static final String EMPTY; static final String[] EMPTY_ARRAY; }