Thanks for the feedback (and for this
amazing library!). I've progressed a bit, so I'll post my findings here, maybe it'll help someone:
Instead of trying to do everything in Scala, I created the indexed collection and added indices in Java from Scala class (and companion object) TestClass:
IndexedCollection<TestClass> testClasses = new ConcurrentIndexedCollection<TestClass>();
testClasses.addIndex(NavigableIndex.onAttribute(TestClass.X_1));
here my IDE cannot resolve symbol X_1, but then changing it to
testClasses.addIndex(NavigableIndex.onAttribute(TestClass.X_1()));
gives
no instance(s) of type variable(s) A exist so that Object confirms to Comparable<A>, which indicates that Scala's Int is not the same as a Java Integer (and definitely not a Java int, which might pose performance problems due to boxing / unboxing, I guess) , and CQEngine (or Java generics) treats it as an object. Fortunately, if I change the definition of X_1 attribute in TestClass companion object to:
final val X_1: Attribute[TestClass, Integer] = new SimpleAttribute[TestClass,Integer]("X_1") {
def getValue(testClass: TestClass, queryOptions: QueryOptions): Integer = testClass.x1
}then it compiles and runs, as Scala's Integer is the same as java.lang.Integer. The same is true for Scala String, it works, but not for Scala Byte, as it is recognised as an Object and not a Java byte, and I didn't even touch enumerations and the like.
So for now, I will stick using Java classes only for CQEngine.