@Test public void testGetAllInterfaces() throws SecurityException { Set<Class<?>> interfaces; final Set<Class<?>> declaredInterfaces = new HashSet<>(); declaredInterfaces.add(MyInterface1.class); interfaces = ClassUtil.getAllInterfaces(MyBean.class); assertEquals(declaredInterfaces.size(), interfaces.size()); assertEquals(declaredInterfaces, interfaces); final Set<Class<?>> inheritedInterfaces = new HashSet<>(); inheritedInterfaces.add(MyInterface2.class); inheritedInterfaces.add(MyInterface4.class); inheritedInterfaces.add(MyInterface3.class); inheritedInterfaces.add(MyInterface1.class); interfaces = ClassUtil.getAllInterfaces(MySubBean.class); assertEquals(inheritedInterfaces.size(), interfaces.size()); assertEquals(inheritedInterfaces, interfaces); }
public static Set<Class<?>> getAllInterfaces(final Class<?> clazz) { Assertion.check() .isNotNull(clazz); Class<?> root = clazz; final Set<Class<?>> allInterfaces = new HashSet<>(); while (root != null) { for (final Class<?> intf : root.getInterfaces()) { allInterfaces.add(intf); for (final Class<?> iIntf : getAllInterfaces(intf)) { allInterfaces.add(iIntf); } } root = root.getSuperclass(); } return Collections.unmodifiableSet(allInterfaces); }
ClassUtil { public static Set<Class<?>> getAllInterfaces(final Class<?> clazz) { Assertion.check() .isNotNull(clazz); Class<?> root = clazz; final Set<Class<?>> allInterfaces = new HashSet<>(); while (root != null) { for (final Class<?> intf : root.getInterfaces()) { allInterfaces.add(intf); for (final Class<?> iIntf : getAllInterfaces(intf)) { allInterfaces.add(iIntf); } } root = root.getSuperclass(); } return Collections.unmodifiableSet(allInterfaces); } }
ClassUtil { public static Set<Class<?>> getAllInterfaces(final Class<?> clazz) { Assertion.check() .isNotNull(clazz); Class<?> root = clazz; final Set<Class<?>> allInterfaces = new HashSet<>(); while (root != null) { for (final Class<?> intf : root.getInterfaces()) { allInterfaces.add(intf); for (final Class<?> iIntf : getAllInterfaces(intf)) { allInterfaces.add(iIntf); } } root = root.getSuperclass(); } return Collections.unmodifiableSet(allInterfaces); } private  ClassUtil(); }
ClassUtil { public static Set<Class<?>> getAllInterfaces(final Class<?> clazz) { Assertion.check() .isNotNull(clazz); Class<?> root = clazz; final Set<Class<?>> allInterfaces = new HashSet<>(); while (root != null) { for (final Class<?> intf : root.getInterfaces()) { allInterfaces.add(intf); for (final Class<?> iIntf : getAllInterfaces(intf)) { allInterfaces.add(iIntf); } } root = root.getSuperclass(); } return Collections.unmodifiableSet(allInterfaces); } private  ClassUtil(); static Object newInstance(final String javaClassName); static J newInstance(final String javaClassName, final Class<J> type); static J newInstance(final Class<J> clazz); static J newInstance(final Constructor<J> constructor, final Object[] args); static Constructor<J> findConstructor(final Class<J> clazz, final Class<?>[] parameterTypes); static Class<?> classForName(final String javaClassName); static Class<? extends J> classForName(final String javaClassName, final Class<J> type); static Object invoke(final Object instance, final Method method, final Object... args); static void set(final Object instance, final Field field, final Object value); static Object get(final Object instance, final Field field); static Method findMethod(final Class<?> clazz, final String methodName, final Class<?>... parameterTypes); static Collection<Field> getAllFields(final Class<?> clazz, final Class<? extends Annotation> annotation); static Collection<Method> getAllMethods(final Class<?> clazz, final Class<? extends Annotation> annotation); static Collection<Field> getAllFields(final Class<?> clazz); static Collection<Method> getAllMethods(final Class<?> clazz); static Set<Class<?>> getAllInterfaces(final Class<?> clazz); static Class<?> getGeneric(final Constructor<?> constructor, final int i); static Class<?> getGeneric(final Method method, final int i); static Class<?> getGeneric(final Field field); static Class<?> getGeneric(
			final Type type,
			final Supplier<RuntimeException> exceptionSupplier); static String getPropertyName(final Method method); }
ClassUtil { public static Set<Class<?>> getAllInterfaces(final Class<?> clazz) { Assertion.check() .isNotNull(clazz); Class<?> root = clazz; final Set<Class<?>> allInterfaces = new HashSet<>(); while (root != null) { for (final Class<?> intf : root.getInterfaces()) { allInterfaces.add(intf); for (final Class<?> iIntf : getAllInterfaces(intf)) { allInterfaces.add(iIntf); } } root = root.getSuperclass(); } return Collections.unmodifiableSet(allInterfaces); } private  ClassUtil(); static Object newInstance(final String javaClassName); static J newInstance(final String javaClassName, final Class<J> type); static J newInstance(final Class<J> clazz); static J newInstance(final Constructor<J> constructor, final Object[] args); static Constructor<J> findConstructor(final Class<J> clazz, final Class<?>[] parameterTypes); static Class<?> classForName(final String javaClassName); static Class<? extends J> classForName(final String javaClassName, final Class<J> type); static Object invoke(final Object instance, final Method method, final Object... args); static void set(final Object instance, final Field field, final Object value); static Object get(final Object instance, final Field field); static Method findMethod(final Class<?> clazz, final String methodName, final Class<?>... parameterTypes); static Collection<Field> getAllFields(final Class<?> clazz, final Class<? extends Annotation> annotation); static Collection<Method> getAllMethods(final Class<?> clazz, final Class<? extends Annotation> annotation); static Collection<Field> getAllFields(final Class<?> clazz); static Collection<Method> getAllMethods(final Class<?> clazz); static Set<Class<?>> getAllInterfaces(final Class<?> clazz); static Class<?> getGeneric(final Constructor<?> constructor, final int i); static Class<?> getGeneric(final Method method, final int i); static Class<?> getGeneric(final Field field); static Class<?> getGeneric(
			final Type type,
			final Supplier<RuntimeException> exceptionSupplier); static String getPropertyName(final Method method);  }