private static void collectAvailableMethods(PsiClass clazz,
                                                PsiClass base,
                                                @NotNull FilterPattern pattern,
                                                List<? super PsiMethod> availableMethods,
                                                HashSet<? super PsiClass> visited) {
        int sortElements = GenerateToStringContext.getConfig().getSortElements();
        if (sortElements == 3) {
            PsiClass superClass = clazz.getSuperClass();
            if (superClass != null && visited.add(superClass)) {
                collectAvailableMethods(superClass, base, pattern, availableMethods, visited);
            }
        }
        PsiMethod[] methods = sortElements != 3 ? clazz.getAllMethods() : clazz.getMethods();
        for (PsiMethod method : methods) {
            // the method should be a getter
            if (!PsiAdapter.isGetterMethod(method)) {
                continue;
            }

            // must not return void
            final PsiType returnType = method.getReturnType();
            if (returnType == null || PsiTypes.voidType().equals(returnType)) {
                continue;
            }

            // method should be public, non static, non abstract
            if (!method.hasModifierProperty(PsiModifier.PUBLIC) || method.hasModifierProperty(PsiModifier.STATIC) ||
                method.hasModifierProperty(PsiModifier.ABSTRACT)) {
                continue;
            }

            // method should not be a getter for an existing field in the same class
            String fieldName = PsiAdapter.getGetterFieldName(method);
            if (base.findFieldByName(fieldName, false) != null) {
                continue;
            }

            // must not be named toString or getClass
            final String methodName = method.getName();
            if ("toString".equals(methodName) || "getClass".equals(methodName) || "hashCode".equals(methodName)) {
                continue;
            }

            // if the method matches the pattern then it shouldn't be in the list of available methods
            if (pattern.methodMatches(method)) {
                continue;
            }

            if (LOG.isDebugEnabled())
                LOG.debug("Adding the method " + methodName + " as there is not a field for this getter");
            availableMethods.add(method);
        }
    }
private static void collectAvailableMethods(PsiClass clazz,
                                                PsiClass base,
                                                @NotNull FilterPattern pattern,
                                                List<? super PsiMethod> availableMethods,
                                                HashSet<? super PsiClass> visited)