@Test
  void integer() {
    IntegerHolderCriteria criteria = IntegerHolderCriteria.integerHolder;
    check(Matchers.toExpression(criteria.value.min()).returnType()).is(Integer.class);
    check(Matchers.toExpression(criteria.value.max()).returnType()).is(Integer.class);
    check(Matchers.toExpression(criteria.value.avg()).returnType()).is(Double.class);
    check(Matchers.toExpression(criteria.value.sum()).returnType()).is(Long.class);
    check(Matchers.toExpression(criteria.value.count()).returnType()).is(Long.class);
    check(Matchers.toExpression(criteria.value).returnType()).is(int.class);

    check(Matchers.toExpression(criteria.optional.min()).returnType()).is(OptionalInt.class);
    check(Matchers.toExpression(criteria.optional.max()).returnType()).is(OptionalInt.class);
    check(Matchers.toExpression(criteria.optional.avg()).returnType()).is(OptionalDouble.class);
    check(Matchers.toExpression(criteria.optional.sum()).returnType()).is(OptionalLong.class);
    check(Matchers.toExpression(criteria.optional.count()).returnType()).is(Long.class);

    check(Matchers.toExpression(criteria.nullable.min()).returnType()).is(OptionalInt.class);
    check(Matchers.toExpression(criteria.nullable.max()).returnType()).is(OptionalInt.class);
    check(Matchers.toExpression(criteria.nullable.avg()).returnType()).is(OptionalDouble.class);
    check(Matchers.toExpression(criteria.nullable.sum()).returnType()).is(OptionalLong.class);
    check(Matchers.toExpression(criteria.nullable.count()).returnType()).is(Long.class);
  }
Check return and projection types for different types of matchers
criteria/common/test/org/immutables/criteria/matcher/ReturnTypeTest.java