On Aug 7, 2009, at 8:57 PM, Marshall Schor wrote:

getViewIterator in CASImpl is written with the signature:
 Iterator<CAS> getViewIterator()

If you are working with things needing CASImpl objects, you would write:

 Iterator<CAS> s = aCas.getViewIterator();
 while (s.hasNext()) {
   CASImpl ci = (CASImpl) s.next();
     ... code using ci...
 }

If we changed the signature to:
 Iterator<T extends CAS> getViewIterator()
then you would write:
 Iterator<CASImpl> s = aCas.getViewIterator(); // cast done inside the
support code, not here
 while (s.hasNext()) {
   CASImpl ci = s.next();  // works OK without casting
     ... code using ci...
 }

Would it be better to have that form of the signature?

+1, though did not know that its possible, we should check other
places too

Jörn

Reply via email to