package org.zalando.logbook.lle;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.PrettyPrinter;

import net.logstash.logback.marker.RawJsonAppendingMarker;

/**
 * 
 * Auto-detecting pretty-printing {@linkplain Marker}. If pretty-printing is enabled,
 * indents using the log framework's own {@linkplain JsonGenerator}. 
 *
 */

public class AutodetectPrettyPrintingMarker extends RawJsonAppendingMarker {
    
    private static final long serialVersionUID = 1L;

    public AutodetectPrettyPrintingMarker(String fieldName, String rawJson) {
        super(fieldName, rawJson);
    }

    @Override
    protected void writeFieldValue(JsonGenerator generator) throws IOException {
        PrettyPrinter prettyPrinter = generator.getPrettyPrinter();
        if(prettyPrinter == null) {
            super.writeFieldValue(generator);
        } else {
            // append to existing tree event by event
            final JsonParser parser = generator.getCodec().getFactory().createParser((String)super.getFieldValue());

            try {
                while (parser.nextToken() != null) {
                    generator.copyCurrentEvent(parser);
                }
            } finally {
                parser.close();
            }
        }
    }


}

@@ -56,16 +56,97 @@
 ption;%0A%0A
+import org.apiguardian.api.API;%0Aimport static org.apiguardian.api.API.Status.*;%0A%0A
 import c
@@ -514,22 +514,50 @@
  *%0A */%0A%0A
-public
+@API(status=INTERNAL)%0Apublic final
  class A

Make AutodetectPrettyPrintingMarker final and part of internal api