package com.github.nsnjson.encoding;

import com.fasterxml.jackson.databind.JsonNode;
import com.github.nsnjson.encoding.style.*;

import java.util.Optional;

public class Encoder {

    private static final Encoding DEFAULT_ENCODING = new DefaultEncoding();

    private static final Encoding ARRAY_STYLE_ENCODING = new ArrayStyleEncoding();

    /**
     * Encodes JSON to NSNJSON presentation.
     * @param data any JSON data
     * @return NSNJSON presentation of JSON
     */
    public static Optional<JsonNode> encode(JsonNode data) {
        return DEFAULT_ENCODING.encode(data);
    }

    /**
     * Encodes JSON to NSNJSON presentation by custom encoding.
     * @param data any JSON data
     * @return NSNJSON presentation of JSON
     */
    public static Optional<JsonNode> encode(JsonNode data, Encoding encoding) {
        return Optional.ofNullable(encoding).orElse(DEFAULT_ENCODING).encode(data);
    }

    public static Optional<JsonNode> encodeWithArrayStyle(JsonNode data) {
        return ARRAY_STYLE_ENCODING.encode(data);
    }

}
@@ -333,24 +333,110 @@
 ncoding();%0A%0A
+    private static final Encoding OBJECT_STYLE_ENCODING = new ObjectStyleEncoding();%0A%0A
     /**%0A    
@@ -1135,9 +1135,143 @@
 %0A    %7D%0A%0A
+    public static Optional%3CJsonNode%3E encodeWithObjectStyle(JsonNode data) %7B%0A        return OBJECT_STYLE_ENCODING.encode(data);%0A    %7D%0A%0A
 %7D

Implement method { Encoder @ encodeWithObjectStyle }