@Test public void capitalizeTest() { assertThat(LangUtils.capitalize(null), is(nullValue())); assertThat(LangUtils.capitalize(""), is("")); assertThat(LangUtils.capitalize("cat"), is("Cat")); assertThat(LangUtils.capitalize("cAt"), is("CAt")); assertThat(LangUtils.capitalize("'cat'"), is("'cat'")); }
public static String capitalize(String s) { if (Strings.isNullOrEmpty(s)) return s; int ch = s.codePointAt(0); if ((Character.getType(ch) & Character.LOWERCASE_LETTER) == 0) return s; ch = Character.toUpperCase(ch); if (Character.isBmpCodePoint(ch)) return ((char) ch) + s.substring(1); else return Character.highSurrogate(ch) + Character.lowSurrogate(ch) + s.substring(2); }
LangUtils { public static String capitalize(String s) { if (Strings.isNullOrEmpty(s)) return s; int ch = s.codePointAt(0); if ((Character.getType(ch) & Character.LOWERCASE_LETTER) == 0) return s; ch = Character.toUpperCase(ch); if (Character.isBmpCodePoint(ch)) return ((char) ch) + s.substring(1); else return Character.highSurrogate(ch) + Character.lowSurrogate(ch) + s.substring(2); } }
LangUtils { public static String capitalize(String s) { if (Strings.isNullOrEmpty(s)) return s; int ch = s.codePointAt(0); if ((Character.getType(ch) & Character.LOWERCASE_LETTER) == 0) return s; ch = Character.toUpperCase(ch); if (Character.isBmpCodePoint(ch)) return ((char) ch) + s.substring(1); else return Character.highSurrogate(ch) + Character.lowSurrogate(ch) + s.substring(2); } private  LangUtils(); }
LangUtils { public static String capitalize(String s) { if (Strings.isNullOrEmpty(s)) return s; int ch = s.codePointAt(0); if ((Character.getType(ch) & Character.LOWERCASE_LETTER) == 0) return s; ch = Character.toUpperCase(ch); if (Character.isBmpCodePoint(ch)) return ((char) ch) + s.substring(1); else return Character.highSurrogate(ch) + Character.lowSurrogate(ch) + s.substring(2); } private  LangUtils(); static boolean isBlank(String s); static boolean containsIgnoreCase(String s, String ss); static String capitalize(String s); static String uncapitalize(String s); static String join(CharSequence delimiter, Stream<?> stream); static String join(CharSequence delimiter, Iterator<?> iterator); static String join(CharSequence delimiter, Iterable<?> iterable); }
LangUtils { public static String capitalize(String s) { if (Strings.isNullOrEmpty(s)) return s; int ch = s.codePointAt(0); if ((Character.getType(ch) & Character.LOWERCASE_LETTER) == 0) return s; ch = Character.toUpperCase(ch); if (Character.isBmpCodePoint(ch)) return ((char) ch) + s.substring(1); else return Character.highSurrogate(ch) + Character.lowSurrogate(ch) + s.substring(2); } private  LangUtils(); static boolean isBlank(String s); static boolean containsIgnoreCase(String s, String ss); static String capitalize(String s); static String uncapitalize(String s); static String join(CharSequence delimiter, Stream<?> stream); static String join(CharSequence delimiter, Iterator<?> iterator); static String join(CharSequence delimiter, Iterable<?> iterable); static final String[] EMPTY_STRING_ARRAY; }