uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marshall Schor <...@schor.com>
Subject generics: getViewIterator
Date Fri, 07 Aug 2009 18:57:01 GMT
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? 

View raw message