public static Set<Method> getOwnMethods(final Class<?> clazz) { final Method[] methods = clazz.getDeclaredMethods(); final Set<Method> declaredMethodSet = CollectionUtils.arrayToSet(methods); final Set<Method> ret = new HashSet<>(); final Set<Method> inheritedMethods = getInheritedMethods(clazz); final Set<Method> overriddenMethods = getOverriddenMethods(clazz); for (final Method declaredMethod : declaredMethodSet) { if (!containMethod(inheritedMethods, declaredMethod) && !containMethod(overriddenMethods, declaredMethod)) { ret.add(declaredMethod); } } return ret; }
public static Set<Method> getInheritedMethods(final Class<?> clazz) { final Method[] methods = clazz.getDeclaredMethods(); final Set<Method> declaredMethodSet = CollectionUtils.arrayToSet(methods); final Set<Method> ret = new HashSet<Method>(declaredMethodSet); Class<?> currentClass = clazz.getSuperclass(); while (currentClass != null) { final Method[] superMethods = currentClass.getDeclaredMethods(); for (Method superMethod : superMethods) { if (!Modifier.isPrivate(superMethod.getModifiers()) && !Modifier.isStatic(superMethod.getModifiers()) && !containMethod(ret, superMethod)) { ret.add(superMethod); } } currentClass = currentClass.getSuperclass(); } ret.removeAll(declaredMethodSet); return ret; }
public static Set<Method> getInheritedMethods(final Class<?> clazz) { final Method[] methods = clazz.getDeclaredMethods(); final Set<Method> declaredMethodSet = CollectionUtils.arrayToSet(methods); final Set<Method> ret = new HashSet<Method>(declaredMethodSet); Class<?> currentClass = clazz.getSuperclass(); while (currentClass != null) { final Method[] superMethods = currentClass.getDeclaredMethods(); for (Method superMethod : superMethods) { if (!Modifier.isPrivate(superMethod.getModifiers()) && !Modifier.isStatic(superMethod.getModifiers()) && !containMethod(ret, superMethod)) { ret.add(superMethod); } } currentClass = currentClass.getSuperclass(); } ret.removeAll(declaredMethodSet); return ret; }
public static Set<Method> getOwnMethods(final Class<?> clazz) { final Method[] methods = clazz.getDeclaredMethods(); final Set<Method> declaredMethodSet = CollectionUtils.arrayToSet(methods); final Set<Method> ret = new HashSet<>(); final Set<Method> inheritedMethods = getInheritedMethods(clazz); final Set<Method> overriddenMethods = getOverriddenMethods(clazz); for (final Method declaredMethod : declaredMethodSet) { if (!containMethod(inheritedMethods, declaredMethod) && !containMethod(overriddenMethods, declaredMethod)) { ret.add(declaredMethod); } } return ret; }