ComparatorModel (@Nullable PsiExpression expression) { expression = PsiUtil.skipParenthesizedExprDown(expression); if (expression == null || NULL_HOSTILE.matches(expression)) { return new NullHostile(); } if (expression instanceof PsiReferenceExpression ref && "CASE_INSENSITIVE_ORDER".equals(ref.getReferenceName()) && ref.resolve() instanceof PsiField field && field.getContainingClass() != null && CommonClassNames.JAVA_LANG_STRING.equals(field.getContainingClass().getQualifiedName())) { return new NullHostile(); } PsiMethodCallExpression call = ObjectUtils.tryCast(expression, PsiMethodCallExpression.class); if (call == null) return new Unknown(expression); PsiExpression qualifier = call.getMethodExpression().getQualifierExpression(); if (REVERSED.test(call) && qualifier != null) { return from(qualifier); } if (REVERSE_ORDER.test(call)) { return from(call.getArgumentList().getExpressions()[0]); } if (NULL_FRIENDLY.test(call) && qualifier != null) { return new NullFriendly(from(qualifier)); } if (KEY_EXTRACTOR.test(call)) { PsiExpression[] args = call.getArgumentList().getExpressions(); PsiExpression keyExtractor = args[0]; ComparatorModel downstream = args.length == 2 ? from(args[1]) : new NullHostile(); return new KeyExtractor(keyExtractor, downstream); } return new Unknown(expression); }