uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thilo Goetz <twgo...@gmx.de>
Subject Re: generics: FSIndexRepository
Date Thu, 13 Aug 2009 10:09:08 GMT
Jörn Kottmann wrote:
> Jörn Kottmann wrote:
>> Jörn Kottmann wrote:
>>> Jörn Kottmann wrote:
>>>> Hi,
>>>>
>>>> after all the discussion we had I think thats the correct
>>>> way to generify FSIndexRepository:
>>>>
>>>> interface FSIndexRepository {
>>>> FSIndex<FeatureStructure> getIndex(String label);
>>>> FSIterator<FeatureStructure> getAllIndexedFS(Type aType);
>>>> ...
>>>> }
>>> It generified now and also getIndexes:
>>> Iterator<FSIndex<FeatureStructure>> getIndexes();
>> Stupid question, but how can a FSIndex<FeatureStructure> be converted
>> into a FSIndex<AnnotationFS> ?  Since casting directy is not possible,
>> do I need to write some kind of adapter which does the casting for me ?
> FSIndex<FeatureStruture> indexFS
> FSIndex<AnnotationFS> indexAnnotationFS = (FSIndex<AnnotationFS>)
> (Object) indexFS;
> 
> Could it be done like this ?
> 
> Jörn

Yes, and it's an excellent example of how screwed up Java
generics are.  BTW, I recommend whatever Angelika Langer
has to say on the topic:
http://www.angelikalanger.com/Articles/Topics.html#JAVA
Some of it is only available in German, but she has English
translations for most of her articles.  She calls this a
"double-fisted cast".

--Thilo



Mime
View raw message