@Nullable
    public static PsiMethod findHashCodeMethod(PsiClass clazz) {
        PsiMethod[] methods = clazz.findMethodsByName("hashCode", false);

        // is it public int hashCode()
        for (PsiMethod method : methods) {
            // must be public
            if (!method.hasModifierProperty(PsiModifier.PUBLIC)) {
                continue;
            }

            // must not be static
            if (method.hasModifierProperty(PsiModifier.STATIC)) {
                continue;
            }

            // must have int as return type
            PsiType returnType = method.getReturnType();
            if (!PsiTypes.intType().equals(returnType)) {
                continue;
            }

            // must not have a parameter
            PsiParameterList parameters = method.getParameterList();
            if (!parameters.isEmpty()) {
                continue;
            }

            // hashCode method found
            return method;
        }

        // hashCode not found
        return null;
    }
@Nullable
    public static PsiMethod findHashCodeMethod(PsiClass clazz)