Marshall Schor wrote:
After generification of iterators, this line in Lucas doesn't compile:

In src/main/java, org.apache.uima.lucas.indexer.analysis,
the class: AnnotationTokenStream
line 340:

    annotationIterator =
Iterators.filter(jCas.getAnnotationIndex(annotationType).iterator(),
            new NotNullPredicate<Annotation>());

gives message:

The method filter(Iterator<T>, Predicate<? super T>) in the type
Iterators is not applicable for the arguments (FSIterator<AnnotationFS>,
AnnotationTokenStream.NotNullPredicate<Annotation>)


I observe that if I change
            new NotNullPredicate<Annotation>());  // to
            new NotNullPredicate<AnnotationFS>());

that the error goes away, but is replaced with another error:

Type mismatch: cannot convert from Iterator<AnnotationFS> to
Iterator<Annotation>

I think the original form assigns to T the value AnnotationFS.  This
makes the assignment of the predicate NotNullPredicate<X> have the type
X be a super type of AnnotationFS.  But Annotation is a subtype, not a
supertype.  So it fails.

I think the JCas version of
getAnnotationIndex(annotationType).iterator() should end up returning an
iterator over Annotation, not AnnotationFS.  This would fix this, I think.
But that would mean that we return an AnnotationIndex<Annotation>
and not AnnotationIndex<AnnotationFS>, right ?

Jörn

Reply via email to