@Override
    String generate(ChainVariable inVar, StreamToLoopReplacementContext context) {
      String sum = context.declareResult("sum", myDoubleAccumulator ? PsiTypes.doubleType() : PsiTypes.longType(), "0", ResultKind.UNKNOWN);
      String count = context.declare("count", "long", "0");
      String seenCheck = count + ">0";
      String result = (myDoubleAccumulator ? "" : "(double)") + sum + "/" + count;
      ConditionalExpression conditionalExpression = myUseOptional ?
                                                    new ConditionalExpression.Optional(PsiTypes.doubleType(), seenCheck, result) :
                                                    new ConditionalExpression.Plain(PsiTypes.doubleType(), seenCheck, result, "0.0");
      context.setFinisher(conditionalExpression);
      return sum + "+=" + inVar + ";\n" + count + "++;\n";
    }
@Override
    String generate(ChainVariable inVar, StreamToLoopReplacementContext context)