@Override
  public int compare(T o1, T o2) {
    if (!(o1 instanceof CharSequence) || !(o2 instanceof CharSequence)) {
      throw new RuntimeException("Attempted use of AvroCharSequenceComparator on non-CharSequence objects: "
          + o1.getClass().getName() + " and " + o2.getClass().getName());
    }
    return compareCharSequence((CharSequence) o1, (CharSequence) o2);
  }
@Test
  void compareUtf8ToString() {
    assertEquals(0, mComparator.compare(new Utf8(""), ""));
    assertThat(mComparator.compare(new Utf8(""), "a"), lessThan(0));
    assertThat(mComparator.compare(new Utf8("a"), ""), greaterThan(0));

    assertEquals(0, mComparator.compare(new Utf8("a"), "a"));
    assertThat(mComparator.compare(new Utf8("a"), "b"), lessThan(0));
    assertThat(mComparator.compare(new Utf8("b"), "a"), greaterThan(0));

    assertEquals(0, mComparator.compare(new Utf8("ab"), "ab"));
    assertThat(mComparator.compare(new Utf8("a"), "aa"), lessThan(0));
    assertThat(mComparator.compare(new Utf8("aa"), "a"), greaterThan(0));

    assertThat(mComparator.compare(new Utf8("abc"), "abcdef"), lessThan(0));
    assertThat(mComparator.compare(new Utf8("abcdef"), "abc"), greaterThan(0));
  }