public Set<Method> getClassMethods() { if (classMethods == null) { synchronized (this) { if (classMethods == null) { final Set<Method> methods = methodSet(); Class<?> clazz = this.indexedClass; while (clazz != null) { methods.addAll(deploymentReflectionIndex.getClassIndex(clazz).getMethods()); clazz = clazz.getSuperclass(); } final Map<Class<?>, Set<Method>> defaultMethodsByInterface = new IdentityHashMap<Class<?>, Set<Method>>(); clazz = this.indexedClass; final Set<MethodIdentifier> foundMethods = new HashSet<MethodIdentifier>(); while (clazz != null) { addDefaultMethods(this.indexedClass, foundMethods, defaultMethodsByInterface, clazz.getInterfaces()); clazz = clazz.getSuperclass(); } for (Set<Method> methodSet : defaultMethodsByInterface.values()) { methods.addAll(methodSet); } this.classMethods = methods; } } } return classMethods; }
public Set<Method> getClassMethods() { if (classMethods == null) { synchronized (this) { if (classMethods == null) { final Set<Method> methods = methodSet(); Class<?> clazz = this.indexedClass; while (clazz != null) { methods.addAll(deploymentReflectionIndex.getClassIndex(clazz).getMethods()); clazz = clazz.getSuperclass(); } final Map<Class<?>, Set<Method>> defaultMethodsByInterface = new IdentityHashMap<Class<?>, Set<Method>>(); clazz = this.indexedClass; final Set<MethodIdentifier> foundMethods = new HashSet<MethodIdentifier>(); while (clazz != null) { addDefaultMethods(this.indexedClass, foundMethods, defaultMethodsByInterface, clazz.getInterfaces()); clazz = clazz.getSuperclass(); } for (Set<Method> methodSet : defaultMethodsByInterface.values()) { methods.addAll(methodSet); } this.classMethods = methods; } } } return classMethods; }
private void addDefaultMethods(final Class<?> componentClass, Set<MethodIdentifier> foundMethods, Map<Class<?>, Set<Method>> defaultMethodsByInterface, Class<?>[] interfaces) { for (Class<?> i : interfaces) { if (! defaultMethodsByInterface.containsKey(i)) { Set<Method> set = methodSet(); defaultMethodsByInterface.put(i, set); final ClassReflectionIndex interfaceIndex = deploymentReflectionIndex.getClassIndex(i); for (Method method : interfaceIndex.getMethods()) { final MethodIdentifier identifier = MethodIdentifier.getIdentifierForMethod(method); if ((method.getModifiers() & (STATIC | PUBLIC | ABSTRACT)) == PUBLIC && ! classContains(componentClass, identifier) && foundMethods.add(identifier)) { set.add(method); } } } addDefaultMethods(componentClass, foundMethods, defaultMethodsByInterface, i.getInterfaces()); } }
private void addDefaultMethods(final Class<?> componentClass, Set<MethodIdentifier> foundMethods, Map<Class<?>, Set<Method>> defaultMethodsByInterface, Class<?>[] interfaces) { for (Class<?> i : interfaces) { if (! defaultMethodsByInterface.containsKey(i)) { Set<Method> set = methodSet(); defaultMethodsByInterface.put(i, set); final ClassReflectionIndex interfaceIndex = deploymentReflectionIndex.getClassIndex(i); for (Method method : interfaceIndex.getMethods()) { final MethodIdentifier identifier = MethodIdentifier.getIdentifierForMethod(method); if ((method.getModifiers() & (STATIC | PUBLIC | ABSTRACT)) == PUBLIC && ! classContains(componentClass, identifier) && foundMethods.add(identifier)) { set.add(method); } } } addDefaultMethods(componentClass, foundMethods, defaultMethodsByInterface, i.getInterfaces()); } }