@Test public void testGetAllInterfaces() throws Exception { Assert.assertEquals(Reflections.getAllInterfaces(A.class), ImmutableList.of(I.class)); Assert.assertEquals(Reflections.getAllInterfaces(B.class), ImmutableList.of(L.class, I.class)); Assert.assertEquals(Reflections.getAllInterfaces(C.class), ImmutableList.of(M.class, K.class, I.class, J.class, L.class)); }
public static List<Class<?>> getAllInterfaces(@Nullable Class<?> type) { Set<Class<?>> found = Sets.newLinkedHashSet(); findAllInterfaces(type, found); return ImmutableList.copyOf(found); }
Reflections { public static List<Class<?>> getAllInterfaces(@Nullable Class<?> type) { Set<Class<?>> found = Sets.newLinkedHashSet(); findAllInterfaces(type, found); return ImmutableList.copyOf(found); } }
Reflections { public static List<Class<?>> getAllInterfaces(@Nullable Class<?> type) { Set<Class<?>> found = Sets.newLinkedHashSet(); findAllInterfaces(type, found); return ImmutableList.copyOf(found); } Reflections(ClassLoader classLoader); }
Reflections { public static List<Class<?>> getAllInterfaces(@Nullable Class<?> type) { Set<Class<?>> found = Sets.newLinkedHashSet(); findAllInterfaces(type, found); return ImmutableList.copyOf(found); } Reflections(ClassLoader classLoader); Reflections applyClassRenames(Map<String,String> newClassRenames); Object loadInstance(String classname, Object...argValues); Object loadInstance(String classname, Class<?>[] argTypes, Object[] argValues); Object loadInstance(String classname); Class<?> loadClass(String classname); @SuppressWarnings("unchecked") Class<? extends T> loadClass(String classname, Class<T> superType); static Class<?> loadInnerClassPossiblyInheritted(Class<?> clazz, String nestedPart); Class<?> loadInnerClassNotInheritted(String outerClassname, String innerClassname); Class<?> loadInnerClassNotInheritted(Class<?> outerClazz, String innerClassname); Constructor<?> loadConstructor(Class<?> clazz, Class<?>[] argTypes); static Optional<T> invokeConstructorWithArgs(ClassLoader classLoader, String className, Object...argsArray); static Optional<T> invokeConstructorWithArgs(ClassLoader classLoader, Class<T> clazz, Object[] argsArray, boolean setAccessible); static Optional<T> invokeConstructorWithArgs(Class<T> clazz, Object...argsArray); static Optional<T> invokeConstructorWithArgs(Class<T> clazz, Object[] argsArray, boolean setAccessible); @SuppressWarnings("unchecked") static Optional<T> invokeConstructorWithArgs(Reflections reflections, Class<T> clazz, Object[] argsArray, boolean setAccessible); Constructor<?> loadSingleConstructor(Class<?> clazz); T loadInstance(Constructor<T> constructor, Object...argValues); Method loadMethod(Class<?> clazz, String methodName, Class<?>[] argTypes); Method loadMethod(Class<?> clazz, String methodName); Object invokeMethod(Method method, Object obj, Object... argValues); Object invokeStaticMethod(Method method, Object... argValues); Object loadStaticField(Class<?> clazz, String fieldname); Object[] loadStaticFields(Class<?> clazz, String[] fieldnamesArray, Object[] defaults); static void copyFields(T source, T target); Class<?> loadClassFromCanonicalName(String canonicalName); @Nullable URL getResource(String r); final Object updateFromNewClassLoader(Object data); ClassLoader getClassLoader(); @SuppressWarnings("unchecked") static Class<? super T> findSuperType(T impl, String typeName); static Set<Class<?>> getInterfacesIncludingClassAncestors(Class<?> clazz); static Method findMethod(Class<?> clazz, String name, Class<?>... parameterTypes); static Field findField(Class<?> clazz, String name); static List<Field> findPublicFieldsOrderedBySuper(Class<?> clazz); static List<Method> findPublicMethodsOrderedBySuper(Class<?> clazz); static Field inferSubbestField(Field f1, Field f2); static Method inferSubbestMethod(Method m1, Method m2); static Class<?> inferSubbest(Class<?> c1, Class<?> c2); @SuppressWarnings("unchecked") static T cast(Object candidate, Class<? extends T> type); static Optional<Object> invokeMethodWithArgs(Object clazzOrInstance, String method, List<Object> args); static Optional<Object> invokeMethodWithArgs(Object clazzOrInstance, String method, List<Object> args, boolean setAccessible); static boolean typesMatch(Object[] argsArray, Class<?>[] parameterTypes); static boolean typesMatchUpTo(Object[] argsArray, Class<?>[] parameterTypes, int lengthRequired); static List<Class<?>> getAllInterfaces(@Nullable Class<?> type); static boolean hasNoArgConstructor(Class<?> clazz); static boolean hasNoNonObjectFields(Class<? extends Object> clazz); static Optional<String> tryFindMappedName(Map<String, String> renames, String name); static String findMappedNameAndLog(Map<String, String> renames, String name); }
Reflections { public static List<Class<?>> getAllInterfaces(@Nullable Class<?> type) { Set<Class<?>> found = Sets.newLinkedHashSet(); findAllInterfaces(type, found); return ImmutableList.copyOf(found); } Reflections(ClassLoader classLoader); Reflections applyClassRenames(Map<String,String> newClassRenames); Object loadInstance(String classname, Object...argValues); Object loadInstance(String classname, Class<?>[] argTypes, Object[] argValues); Object loadInstance(String classname); Class<?> loadClass(String classname); @SuppressWarnings("unchecked") Class<? extends T> loadClass(String classname, Class<T> superType); static Class<?> loadInnerClassPossiblyInheritted(Class<?> clazz, String nestedPart); Class<?> loadInnerClassNotInheritted(String outerClassname, String innerClassname); Class<?> loadInnerClassNotInheritted(Class<?> outerClazz, String innerClassname); Constructor<?> loadConstructor(Class<?> clazz, Class<?>[] argTypes); static Optional<T> invokeConstructorWithArgs(ClassLoader classLoader, String className, Object...argsArray); static Optional<T> invokeConstructorWithArgs(ClassLoader classLoader, Class<T> clazz, Object[] argsArray, boolean setAccessible); static Optional<T> invokeConstructorWithArgs(Class<T> clazz, Object...argsArray); static Optional<T> invokeConstructorWithArgs(Class<T> clazz, Object[] argsArray, boolean setAccessible); @SuppressWarnings("unchecked") static Optional<T> invokeConstructorWithArgs(Reflections reflections, Class<T> clazz, Object[] argsArray, boolean setAccessible); Constructor<?> loadSingleConstructor(Class<?> clazz); T loadInstance(Constructor<T> constructor, Object...argValues); Method loadMethod(Class<?> clazz, String methodName, Class<?>[] argTypes); Method loadMethod(Class<?> clazz, String methodName); Object invokeMethod(Method method, Object obj, Object... argValues); Object invokeStaticMethod(Method method, Object... argValues); Object loadStaticField(Class<?> clazz, String fieldname); Object[] loadStaticFields(Class<?> clazz, String[] fieldnamesArray, Object[] defaults); static void copyFields(T source, T target); Class<?> loadClassFromCanonicalName(String canonicalName); @Nullable URL getResource(String r); final Object updateFromNewClassLoader(Object data); ClassLoader getClassLoader(); @SuppressWarnings("unchecked") static Class<? super T> findSuperType(T impl, String typeName); static Set<Class<?>> getInterfacesIncludingClassAncestors(Class<?> clazz); static Method findMethod(Class<?> clazz, String name, Class<?>... parameterTypes); static Field findField(Class<?> clazz, String name); static List<Field> findPublicFieldsOrderedBySuper(Class<?> clazz); static List<Method> findPublicMethodsOrderedBySuper(Class<?> clazz); static Field inferSubbestField(Field f1, Field f2); static Method inferSubbestMethod(Method m1, Method m2); static Class<?> inferSubbest(Class<?> c1, Class<?> c2); @SuppressWarnings("unchecked") static T cast(Object candidate, Class<? extends T> type); static Optional<Object> invokeMethodWithArgs(Object clazzOrInstance, String method, List<Object> args); static Optional<Object> invokeMethodWithArgs(Object clazzOrInstance, String method, List<Object> args, boolean setAccessible); static boolean typesMatch(Object[] argsArray, Class<?>[] parameterTypes); static boolean typesMatchUpTo(Object[] argsArray, Class<?>[] parameterTypes, int lengthRequired); static List<Class<?>> getAllInterfaces(@Nullable Class<?> type); static boolean hasNoArgConstructor(Class<?> clazz); static boolean hasNoNonObjectFields(Class<? extends Object> clazz); static Optional<String> tryFindMappedName(Map<String, String> renames, String name); static String findMappedNameAndLog(Map<String, String> renames, String name);  }