@Test
  protected void optional() {
    repository.insert(generator.get().withValue("null").withNullable(null).withOptional(Optional.empty()));
    repository.insert(generator.get().withValue("notnull").withNullable("notnull").withOptional("notempty"));

    values(string.optional.isAbsent()).isOf("null");
    values(string.optional.isPresent()).isOf("notnull");
    values(string.optional.is("null")).isEmpty();
    values(string.optional.is("notempty")).isOf("notnull");
    values(string.optional.is("")).isEmpty();

    // using OptionalValue matcher API
    values(string.optional.is(Optional.empty())).isOf("null");
    values(string.optional.isNot(Optional.empty())).isOf("notnull");
    values(string.optional.is(Optional.of("notempty"))).isOf("notnull");
  }
Testing various string operations prefix/suffix/length etc.
criteria/common/test/org/immutables/criteria/typemodel/StringTemplate.java