Thilo Goetz wrote:
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".
Could not find the part where she talks about double fisted casts
and googling for it was not successful also.
Do you have a link ?
Jörn