uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörn Kottmann <kottm...@gmail.com>
Subject Re: generics: AnnotationIndex.subiterator
Date Tue, 25 Aug 2009 09:30:44 GMT
Jörn Kottmann wrote:
> FSIterator<T> subiterator(AnnotationFS annot);
>
> Is that correct ?
>
> It leads to a problem in the Subiterator class, because it calls
> moveTo(annot) on an FSIterator, but  annot must not have type
> T.
The AnnotationIndexImpl has this method

  public FSIterator<AnnotationFS> subiterator(AnnotationFS annot, 
boolean ambiguous, boolean strict) {
    return new Subiterator<AnnotationFS>(this.index.iterator(), annot, 
ambiguous, strict);
  }

if now the AnnotationFS is replaced by a T which is defined as T extends 
AnnotationFS then,
the method is changed to
  public FSIterator<T> subiterator(AnnotationFS annot, boolean 
ambiguous, boolean strict) {
    return new Subiterator<T>(this.index.iterator(), annot, ambiguous, 
strict);
  }
which leads to a compile error because Subiterator expects annot to be 
of type T and not of
type AnnotationFS. Subitertor calls on the passed iterator moveTo(annot) 
which creates a
conflict here.

Jörn

Mime
View raw message