@Test void getAllMethods() { Collection<Method> methods = ReflectionUtils.getAllMethods(AllMethodsTestClass.class); List<String> methodSignatures = new ArrayList<>(); for (Method method : methods) { methodSignatures.add(method.toString()); } assertThat(methodSignatures, hasItems( "public void org.xwiki.component.util.ReflectionUtilsTest$AllMethodsTestClass.publicMethod()", "public void org.xwiki.component.util.ReflectionUtilsTest$AllMethodsTestSuperClass.publicParentMethod()", "void org.xwiki.component.util.ReflectionUtilsTest$AllMethodsTestClass.packageLevelMethod()", "void org.xwiki.component.util.ReflectionUtilsTest$AllMethodsTestSuperClass.packageLeveLParentMethod()", "private void org.xwiki.component.util.ReflectionUtilsTest$AllMethodsTestClass.privateMethod()", "private void org.xwiki.component.util.ReflectionUtilsTest$AllMethodsTestSuperClass.privateParentMethod()", "protected void org.xwiki.component.util.ReflectionUtilsTest$AllMethodsTestClass.protectedMethod()", "protected void org.xwiki.component.util.ReflectionUtilsTest$AllMethodsTestSuperClass." + "protectedParentMethod()", "protected void org.xwiki.component.util.ReflectionUtilsTest$AllMethodsTestClass." + "protectedOverridenMethod()")); assertThat(methodSignatures, not(hasItems( "protected void org.xwiki.component.util.ReflectionUtilsTest$AllMethodsTestSuperClass." + "protectedOverridenMethod()"))); }
@Unstable public static Collection<Method> getAllMethods(Class<?> clazz) { Set<Method> methods = new LinkedHashSet<>(); Collections.addAll(methods, clazz.getMethods()); Map<Object, Set<Package>> types = new HashMap<>(); Set<Package> pkgIndependent = Collections.emptySet(); for (Method method : methods) { types.put(getMethodSignature(method), pkgIndependent); } for (Class<?> current = clazz; current != null; current = current.getSuperclass()) { addDeclaredMethodsForClass(current, methods, types, pkgIndependent); } return methods; }
ReflectionUtils { @Unstable public static Collection<Method> getAllMethods(Class<?> clazz) { Set<Method> methods = new LinkedHashSet<>(); Collections.addAll(methods, clazz.getMethods()); Map<Object, Set<Package>> types = new HashMap<>(); Set<Package> pkgIndependent = Collections.emptySet(); for (Method method : methods) { types.put(getMethodSignature(method), pkgIndependent); } for (Class<?> current = clazz; current != null; current = current.getSuperclass()) { addDeclaredMethodsForClass(current, methods, types, pkgIndependent); } return methods; } }
ReflectionUtils { @Unstable public static Collection<Method> getAllMethods(Class<?> clazz) { Set<Method> methods = new LinkedHashSet<>(); Collections.addAll(methods, clazz.getMethods()); Map<Object, Set<Package>> types = new HashMap<>(); Set<Package> pkgIndependent = Collections.emptySet(); for (Method method : methods) { types.put(getMethodSignature(method), pkgIndependent); } for (Class<?> current = clazz; current != null; current = current.getSuperclass()) { addDeclaredMethodsForClass(current, methods, types, pkgIndependent); } return methods; } private  ReflectionUtils(); }
ReflectionUtils { @Unstable public static Collection<Method> getAllMethods(Class<?> clazz) { Set<Method> methods = new LinkedHashSet<>(); Collections.addAll(methods, clazz.getMethods()); Map<Object, Set<Package>> types = new HashMap<>(); Set<Package> pkgIndependent = Collections.emptySet(); for (Method method : methods) { types.put(getMethodSignature(method), pkgIndependent); } for (Class<?> current = clazz; current != null; current = current.getSuperclass()) { addDeclaredMethodsForClass(current, methods, types, pkgIndependent); } return methods; } private  ReflectionUtils(); static Collection<Field> getAllFields(Class<?> clazz); static Field getField(Class<?> clazz, String fieldName); static Class getTypeClass(Type type); static void setFieldValue(Object instanceContainingField, String fieldName, Object fieldValue); static Class<?> getLastGenericFieldType(Field field); static Type getLastFieldGenericArgument(Field field); static Type getLastTypeGenericArgument(Type type); static Class<?> getLastGenericClassType(Class clazz, Class filterClass); static Type getGenericClassType(Class clazz, Class filterClass); static Type[] resolveSuperArguments(Type[] parameters, Type childType); static Type[] resolveSuperArguments(Type[] parameters, Class childClass, Type[] childParameters); static Type resolveType(Type type, Map<TypeVariable, Type> typeMapping); static Type resolveType(Type targetType, Type rootType); static Type unserializeType(String serializedType, ClassLoader classLoader); static T getDirectAnnotation(Class<T> annotationClass, AnnotatedElement element); static List<Type> getDirectTypes(Type type); @Unstable static String serializeType(Type type); @Unstable static Collection<Method> getAllMethods(Class<?> clazz); }
ReflectionUtils { @Unstable public static Collection<Method> getAllMethods(Class<?> clazz) { Set<Method> methods = new LinkedHashSet<>(); Collections.addAll(methods, clazz.getMethods()); Map<Object, Set<Package>> types = new HashMap<>(); Set<Package> pkgIndependent = Collections.emptySet(); for (Method method : methods) { types.put(getMethodSignature(method), pkgIndependent); } for (Class<?> current = clazz; current != null; current = current.getSuperclass()) { addDeclaredMethodsForClass(current, methods, types, pkgIndependent); } return methods; } private  ReflectionUtils(); static Collection<Field> getAllFields(Class<?> clazz); static Field getField(Class<?> clazz, String fieldName); static Class getTypeClass(Type type); static void setFieldValue(Object instanceContainingField, String fieldName, Object fieldValue); static Class<?> getLastGenericFieldType(Field field); static Type getLastFieldGenericArgument(Field field); static Type getLastTypeGenericArgument(Type type); static Class<?> getLastGenericClassType(Class clazz, Class filterClass); static Type getGenericClassType(Class clazz, Class filterClass); static Type[] resolveSuperArguments(Type[] parameters, Type childType); static Type[] resolveSuperArguments(Type[] parameters, Class childClass, Type[] childParameters); static Type resolveType(Type type, Map<TypeVariable, Type> typeMapping); static Type resolveType(Type targetType, Type rootType); static Type unserializeType(String serializedType, ClassLoader classLoader); static T getDirectAnnotation(Class<T> annotationClass, AnnotatedElement element); static List<Type> getDirectTypes(Type type); @Unstable static String serializeType(Type type); @Unstable static Collection<Method> getAllMethods(Class<?> clazz);  }