vendredi 22 juillet 2016

How can I get an element of a HashSet with reflection?

I'm trying to get the type of an array elements. I got something like this:

Set<Foo> mySet = new HashSet<Foo>();

I have to take via reflection the 'Foo' as a String. I tried something like this:

if (className.equals("java.util.HashSet")){
        Object arrayElement = Array.get(value, 0);
        isComplex = isComplex(field, arrayElement);
}

Array.get() is only for ArrayList and there isn't any HashSet.iterator()as Util

Thanks!





Aucun commentaire:

Enregistrer un commentaire