/** * Returns set of all effective interfaces implied by a given interface. This set is constructed * by traversing the interface inheritance hierarchy from the given interface to the root(s) of * the hierarchy, collecting all interfaces along the way, including the starting interface. * * @param itfClass interface class where the traversal should start * @return set of all effective interfaces implied by the given interface */ public static Set<Class<?>> getEffectiveInterfaces(final Class<?> itfClass) { // // Traverse the hierarchy in a breadth-first manner. Add newly visited // interfaces to the result set and their super interfaces to the queue // of interfaces to visit. // final Set<Class<?>> result = Sets.newHashSet(); final Queue<Class<?>> queue = Lists.newLinkedList(); queue.add(itfClass); while (!queue.isEmpty()) { final Class<?> itf = queue.poll(); result.add(itf); for (final Class<?> superItf : itf.getInterfaces()) { if (!result.contains(superItf)) { queue.add(superItf); } } } return result; }