static Optional<Integer> typePrefixLength(List<String> nameParts) {
    TyParseState state = TyParseState.START;
    Optional<Integer> typeLength = Optional.empty();
    for (int i = 0; i < nameParts.size(); i++) {
      state = state.next(JavaCaseFormat.from(nameParts.get(i)));
      if (state == TyParseState.REJECT) {
        break;
      }
      if (state.isSingleUnit()) {
        typeLength = Optional.of(i);
      }
    }
    return typeLength;
  }
@Test
  public void typePrefixLength() {
    assertThat(getPrefix("fieldName")).isEmpty();
    assertThat(getPrefix("CONST")).isEmpty();
    assertThat(getPrefix("ClassName")).hasValue(0);
    assertThat(getPrefix("com.ClassName")).hasValue(1);
    assertThat(getPrefix("ClassName.foo")).hasValue(1);
    assertThat(getPrefix("com.ClassName.foo")).hasValue(2);
    assertThat(getPrefix("ClassName.foo.bar")).hasValue(1);
    assertThat(getPrefix("com.ClassName.foo.bar")).hasValue(2);
    assertThat(getPrefix("ClassName.CONST")).hasValue(1);
    assertThat(getPrefix("ClassName.varName")).hasValue(1);
    assertThat(getPrefix("ClassName.Inner.varName")).hasValue(2);
    assertThat(getPrefix("com.R.foo")).hasValue(2);
  }