@Override
  public StringBuilder visitPartition_with_stream(
      @NotNull SiddhiQLParser.Partition_with_streamContext ctx) {
    StringBuilder partitionWith = new StringBuilder(" \"PartitionWith\": [{  ");

    partitionWith
        .append(" \"Partition_Stream\":\"")
        .append(ctx.stream_id().getText())
        .append("\", ");

    List<String> condition = new ArrayList<String>();
    List<String> attribute = new ArrayList<String>();

    if (ctx.condition_ranges() != null) {
      for (SiddhiQLParser.Condition_rangeContext context :
          ctx.condition_ranges().condition_range()) {
        condition.add(
            "\""
                + excapeCode(
                    tokenStreamRewriter
                        .getTokenStream()
                        .getText(context.expression().getStart(), context.expression().getStop()))
                + "\"");
        attribute.add("\"" + context.string_value().getText() + "\"");
      }
      partitionWith.append(" \"condition\":").append(condition).append(", ");
      partitionWith.append(" \"attribute\":").append(attribute).append(" ");

    } else if (ctx.attribute() != null) {
      condition.add("null");
      attribute.add("\"" + ctx.attribute().getText() + "\"");
      partitionWith.append(" \"condition\":").append(condition).append(", ");
      partitionWith.append(" \"attribute\":").append(attribute).append("  ");
    }
    partitionWith = new StringBuilder(partitionWith.substring(0, partitionWith.length() - 1));
    partitionWith.append(" }],");

    return partitionWith;
  }
  @Override
  public StringBuilder visitPartition(@NotNull SiddhiQLParser.PartitionContext ctx) {
    StringBuilder partitionText = new StringBuilder(" { \"Partition\":  ");

    for (SiddhiQLParser.Partition_with_streamContext with_streamContext :
        ctx.partition_with_stream()) {
      String pw_Text =
          excapeCode(
              tokenStreamRewriter
                  .getTokenStream()
                  .getText(with_streamContext.getStart(), with_streamContext.getStop()));
      partitionText.append("  [{  \"Partition_with_Text\":\"").append(pw_Text).append("\", ");
    }

    for (SiddhiQLParser.Partition_with_streamContext with_streamContext :
        ctx.partition_with_stream()) {
      partitionText.append(visitPartition_with_stream(with_streamContext));
    }

    partitionText.append(" \"Query_size\":").append(ctx.query().size()).append(",");

    for (int i = 0; i < ctx.query().size(); i++) {
      SiddhiQLParser.QueryContext queryContext = ctx.query().get(i);
      partitionText
          .append("\"Query_" + i + "\" : [")
          .append(visitQuery(queryContext))
          .append("], ");
    }
    String p_Text =
        excapeCode(tokenStreamRewriter.getTokenStream().getText(ctx.getStart(), ctx.getStop()));
    partitionText.append(" \"Partition_Text\":\"").append(p_Text).append("\",");

    partitionText = new StringBuilder(partitionText.substring(0, partitionText.length() - 1));
    partitionText.append(" }]}");

    return partitionText;
  }