String (@NotNull List<ComparisonBlock> blocks, @NotNull PsiVariable firstVar, @NotNull PsiVariable secondVar) { if (blocks.size() < 2) return null; ComparisonBlock first = blocks.get(0); StringBuilder builder = new StringBuilder(); PsiType type = secondVar.getType(); String name = suggestVarName(firstVar); if(name == null) return null; PsiExpression firstKey = first.getKey(); String firstMethodName = getComparingMethodName(firstKey.getType(), true); if(firstMethodName == null) return null; builder.append(CommonClassNames.JAVA_UTIL_COMPARATOR).append(".") .append(generateComparison(firstMethodName, type, name, firstKey, secondVar)); for (int i = 1; i < blocks.size(); i++) { ComparisonBlock block = blocks.get(i); PsiExpression blockKey = block.getKey(); String comparatorMethodName = getComparingMethodName(blockKey.getType(), false); if(comparatorMethodName == null) return null; builder.append(".").append(generateComparison(comparatorMethodName, null, name, blockKey, secondVar)); } return builder.toString(); }