Get all objects of a specific class from a root object

Cricket1650

New Member
From a root object I would like to get all fields of specific class (recursively).The signature of the method could look something like this:\[code\]private static <T> Set<T> findObjectsOfClass(Object root, Class<T> classToFind)\[/code\]I have tried some implementations myself, but I always end up with lots of special cases (for example for handling arrays and primitives) and it looks like I will miss some specific case.Note: I'm not looking for a library.
 
Back
Top