boolean (@Nullable PsiMethod method, @NotNull Set<PsiField> fields) { if (method == null) return false; /* Finds equals in the form public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj.getClass() != this.getClass()) return false; var that = (Person)obj; return Objects.equals(this.name, that.name) && this.age == that.age; } */ PsiCodeBlock body = method.getBody(); if (body == null) return false; PsiParameter parameter = method.getParameterList().getParameter(0); PsiStatement[] statements = body.getStatements(); int shift; if (statements.length == 4) { if (!isThisCheck(statements[0], parameter)) return false; shift = 1; } else { if (statements.length != 3) return false; shift = 0; } if (!isNullClassCheck(statements[shift], parameter)) return false; PsiVariable that = extractThatVariable(statements[1 + shift], parameter); if (that == null) return false; if (!(statements[2 + shift] instanceof PsiReturnStatement returnStatement)) return false; if (!(PsiUtil.skipParenthesizedExprDown(returnStatement.getReturnValue()) instanceof PsiPolyadicExpression poly)) return false; if (!poly.getOperationTokenType().equals(JavaTokenType.ANDAND)) return false; PsiExpression[] operands = poly.getOperands(); if (fields.size() != operands.length) return false; Set<PsiField> comparedFields = new HashSet<>(); for (PsiExpression operand : operands) { PsiField field = getComparedField(operand, that); if (field == null || !comparedFields.add(field)) return false; } return comparedFields.equals(fields); }