void (@NotNull PsiElement element, @NotNull ConditionalModel model) { PsiBinaryExpression condition = getCondition(model.getCondition()); if (condition == null) return; PsiExpression left = condition.getLOperand(); if (SideEffectChecker.mayHaveSideEffects(left, e -> e instanceof PsiMethodCallExpression)) return; PsiType leftType = getType(left); if (leftType == null) return; PsiExpression right = condition.getROperand(); if (right == null || SideEffectChecker.mayHaveSideEffects(right, e -> e instanceof PsiMethodCallExpression)) return; PsiType rightType = getType(right); if (rightType == null || leftType != rightType) return; EquivalenceChecker equivalenceChecker = EquivalenceChecker.getCanonicalPsiEquivalence(); boolean useMathMin = equivalenceChecker.expressionsAreEquivalent(left, model.getElseExpression()); if (!useMathMin && !equivalenceChecker.expressionsAreEquivalent(left, model.getThenExpression())) return; if (!equivalenceChecker.expressionsAreEquivalent(right, useMathMin ? model.getThenExpression() : model.getElseExpression())) return; IElementType tokenType = condition.getOperationTokenType(); useMathMin ^= JavaTokenType.LT.equals(tokenType) || JavaTokenType.LE.equals(tokenType); PsiClass containingClass = ClassUtils.getContainingClass(element); if (containingClass != null && CommonClassNames.JAVA_LANG_MATH.equals(containingClass.getQualifiedName())) return; holder.registerProblem(element, JavaBundle.message("inspection.manual.min.max.calculation.description", useMathMin ? "min" : "max"), new ReplaceWithMinMaxFix(useMathMin)); }