ReplaceInfo () { return new ComplexReplaceInfo() { private final static String COMPARE_TO = "compareTo"; private final static SimpleReplaceInfo fallback = ReplaceInfo.available(true, "toString"); @Override public String valueMethod() { return fallback.valueMethod(); } private static boolean isApplicable(PsiElement psiElement) { return PsiUtil.isLanguageLevel11OrHigher(psiElement); } @Override public void fill(@NotNull PsiExpression argument, @NotNull PsiExpression qualifier, @NotNull StringBuilder builder, @NotNull CommentTracker ct) { if (!isApplicable(argument)) { EqualsOnSuspiciousObjectFix.fillSimple(fallback, argument, qualifier, builder, ct); return; } builder.append(ct.text(qualifier, ParenthesesUtils.METHOD_CALL_PRECEDENCE)) .append(".") .append(COMPARE_TO) .append("(") .append(ct.text(argument)) .append(")") .append(" == 0"); } }; }