/** * * * @param entity */ public static AMethodMeta[] getImplementedMethod(AMethodMeta entity) { String methodName = entity.getName(); IClass[] argClasses = entity.getParameterTypes() == null ? new IClass[0] : entity.getParameterTypes(); List<AMethodMeta> foundList = new ArrayList<>(); List<IClass> interfaces = IClassUtils.getAllInterfaces(entity.getActuallyOwner()); for (IClass inter : interfaces) { AMethodMeta method = inter.getDeclaredMethod(methodName, argClasses); if (method != null && !containsSameSignature(foundList, method)) { foundList.add(method); } } return foundList.toArray(new AMethodMeta[foundList.size()]); }
/** * Return a method, that have overrided by passed method. * * @param entity the override method */ public static AMethodMeta getOverriddenMethod(AMethodMeta entity) { IClass superClass = entity.getActuallyOwner().getSuperclass(); String methodName = entity.getName(); IClass[] argClasses = entity.getParameterTypes() == null ? new IClass[0] : entity.getParameterTypes(); for (; superClass != null && !Object.class.equals(superClass);) { AMethodMeta method = superClass.getDeclaredMethod(methodName, argClasses); if(method != null) { IClass callerOwner = entity.getActuallyOwner(); IClass calledOwner = method.getActuallyOwner(); if (IClassUtils.visible(callerOwner, calledOwner, calledOwner, method.getModifiers())) { return method; } } superClass = superClass.getSuperclass(); } return null; }