MutableCharArrayUtils { public static boolean toLowerCase(MutableCharArray source, MutableCharArray result) { char[] buffer = result.getBuffer(); final int length = source.length(); if (buffer.length < length) { buffer = new char[length]; } final boolean changed = CharArrayUtils.toLowerCase(source.getBuffer(), buffer, source.getStart(), source.length()); result.reset(buffer, 0, length); return changed; }  static boolean toLowerCase(MutableCharArray source, MutableCharArray result);  }
@Test public void toLowerCaseNoReallocation() { final MutableCharArray source = new MutableCharArray("ŁÓdŹ"); final MutableCharArray result = new MutableCharArray(" z"); Assertions.assertThat(MutableCharArrayUtils.toLowerCase(source, result)).isTrue(); Assertions.assertThat(result.getBuffer()).isEqualTo("łódźz".toCharArray()); }
@Test public void toLowerCaseNoWithReallocation() { final MutableCharArray source = new MutableCharArray("ŁÓdŹ"); final MutableCharArray result = new MutableCharArray("abc"); Assertions.assertThat(MutableCharArrayUtils.toLowerCase(source, result)).isTrue(); Assertions.assertThat(result.getBuffer()).isEqualTo("łódź".toCharArray()); }