On Wed, Aug 12, 2009 at 5:36 AM, Jörn Kottmann<kottm...@gmail.com> wrote: > Jörn Kottmann wrote: >> >> Marshall Schor wrote: >>> >>> I'll probably stop trying to convince others if they continue to feel >>> that the tradeoffs here should be in the direction of returning only >>> specific types (disallowing users from specifying downcasting in that >>> manner), versus using types of the form T extends X, >>> which allows users to specify downcasting. >>> >> >> The case of FSIndexRepository is maybe more clear >> then the other cases in our API. >> >> With down casting it could be changed to >> >> interface FSIndexRepository { >> <T extends FeatureStructure> FSIndex<T> getIndex(String label); >> <T extends FeatureStructure> FSIterator<T> getAllIndexedFS(Type aType); >> ... >> } >> >> and then a user could write >> >> FSIndex<AnnotationFS> index = repo.getIndex(...); >> FSIterator<AnnotationFS> it = repo.getAllIndexedFS(...); > > Any opinions on this ? Right now the class is not generified but I > would like to change that before the release. >
I say no since like our other discussions, I don't like cases where there's no guarantee of correctness. A user can write: FSIterator<AnnotationFS> it = repo.getAllIndexedFS(someNonAnnotationTypeCode); and it would compile even though it doesn't make sense. Something like this for JCas, on the other hand, does make sense to me: FSIterator<T extends TOP> getAllIndexedFS(Class<T> jcasType) which is called like FSIterator<MyAnnotationType> it = jcas.getAllIndexedFS(MyAnnotationType.class); -Adam