I have tree classes ClassA, ClassB and ClassC. ClassA and ClassB extends ClassC. I have merged Multimap<ClassC> and I have Collection of objects of different types. I wold like to get this objects from Collection but how to distinguish this objects? I have created Collection<? super ClassC> coll = multimap.get(key) and I wold like to get this objects using trnasform method but I don’t know how to distinguish object’s type. Can you give me advice? I appreciate every help.
I have tree classes ClassA , ClassB and ClassC . ClassA and ClassB extends
Share
By the sound of it you actually need to filter the collection down to the types you want:
Update from @EtienneNeveu using the overload
Iterables.filter(Iterable<?> unfiltered, Class<T> type)removes any type issues with my original answer.