ASCII { public static String toLowerCase(@Nullable String text) { if (text == null) return null; int length = text.length(); for (int i = 0; i < length; i++) { if (isUpperCase(text.charAt(i))) { char[] chars = text.toCharArray(); for (int j = i; j < length; j++) { char ch = chars[j]; if (isUpperCase(ch)) { chars[j] = (char) (ch ^ 0x20); } } return String.valueOf(chars); } } return text; }  static String toUpperCase(@Nullable String text); static char toUpperCase(char ch); static String toLowerCase(@Nullable String text); static char toLowerCase(char ch); static boolean isLowerCase(char ch); static boolean isUpperCase(char ch); static boolean isDigit(char ch); static boolean isLetter(char ch);  }
@Test void toLowerCase() { assertThat(ASCII.toLowerCase(null)).isNull(); assertThat(ASCII.toLowerCase("text")).isEqualTo("text"); assertThat(ASCII.toLowerCase("tExt")).isEqualTo("text"); assertThat(ASCII.toLowerCase("TEXT")).isEqualTo("text"); assertThat(ASCII.toLowerCase("01239_-")).isEqualTo("01239_-"); }
@Test void toLowerCaseChar() { assertThat(ASCII.toLowerCase('-')).isEqualTo('-'); assertThat(ASCII.toLowerCase('a')).isEqualTo('a'); assertThat(ASCII.toLowerCase('z')).isEqualTo('z'); assertThat(ASCII.toLowerCase('0')).isEqualTo('0'); assertThat(ASCII.toLowerCase('9')).isEqualTo('9'); assertThat(ASCII.toLowerCase('A')).isEqualTo('a'); assertThat(ASCII.toLowerCase('Z')).isEqualTo('z'); }