String (CommentTracker ct, boolean strictMode) { String downstreamCollector = myDownstream.generateCollector(ct, strictMode); PsiVariable elementVariable = myDownstream.getElementVariable(); if (!ExpressionUtils.isReferenceTo(myDownstream.getMapping(), myDownstream.getElementVariable())) { downstreamCollector = JAVA_UTIL_STREAM_COLLECTORS + ".mapping(" + myDownstream.getElementVariable().getName() + "->" + ct.text(myDownstream.getMapping()) + "," + downstreamCollector + ")"; } StringBuilder builder = new StringBuilder(); builder.append(".collect(" + JAVA_UTIL_STREAM_COLLECTORS + ".groupingBy(") .append(ct.lambdaText(elementVariable, myKeyExpression)); PsiLocalVariable variable = Objects.requireNonNull(getTargetVariable()); PsiExpression initializer = variable.getInitializer(); LOG.assertTrue(initializer != null); if (!isHashMap(variable)) { builder.append(",()->").append(ct.text(initializer)).append(",").append(downstreamCollector); } else if (!(JAVA_UTIL_STREAM_COLLECTORS + "." + "toList()").equals(downstreamCollector)) { builder.append(",").append(downstreamCollector); } builder.append("))"); return builder.toString(); }