boolean (@NotNull PsiElement element) { if (!(element instanceof PsiMethod method)) { return false; } if (!"toString".equals(method.getName())) { return false; } if (method.getParameters().length != 0) { return false; } PsiType returnType = method.getReturnType(); return returnType != null && returnType.equalsToText(CommonClassNames.JAVA_LANG_STRING); }