package com.github.terma.gigaspacewebconsole.provider;

import com.gigaspaces.document.DocumentProperties;
import com.gigaspaces.entry.VirtualEntry;
import com.google.gson.*;

import java.lang.reflect.Type;

public class DocumentConverter {

    private static final JsonSerializer<VirtualEntry> VIRTUAL_ENTRY_SERIALIZER =
            new JsonSerializer<VirtualEntry>() {

                @Override
                public JsonElement serialize(
                        final VirtualEntry virtualEntry, final Type type,
                        final JsonSerializationContext jsonSerializationContext) {
                    JsonObject jsonObject = new JsonObject();
                    jsonObject.addProperty("typeName", virtualEntry.getTypeName());
                    jsonObject.add("properties", jsonSerializationContext.serialize(virtualEntry.getProperties()));
                    return jsonObject;
                }

            };

//    private static final JsonSerializer<DocumentProperties> DOCUMENT_PROPERTIES_SERIALIZER =
//            new JsonSerializer<VirtualEntry>() {
//
//                @Override
//                public JsonElement serialize(
//                        final DocumentProperties documentProperties, final Type type,
//                        final JsonSerializationContext jsonSerializationContext) {
//                    JsonObject jsonObject = new JsonObject();
//                    jsonObject.add("properties", jsonSerializationContext.serialize(documentProperties.()));
//                    return jsonObject;
//                }
//
//            };

    private static final Gson GSON = new GsonBuilder()
            .registerTypeHierarchyAdapter(VirtualEntry.class, VIRTUAL_ENTRY_SERIALIZER)
            .disableHtmlEscaping()
            .setPrettyPrinting()
            .create();

    public static String convert(final Object o) {
        if (o instanceof VirtualEntry || o instanceof DocumentProperties) return GSON.toJson(o);
        else return null;
    }

}

@@ -935,663 +935,8 @@
 %7D;%0A%0A
-//    private static final JsonSerializer%3CDocumentProperties%3E DOCUMENT_PROPERTIES_SERIALIZER =%0A//            new JsonSerializer%3CVirtualEntry%3E() %7B%0A//%0A//                @Override%0A//                public JsonElement serialize(%0A//                        final DocumentProperties documentProperties, final Type type,%0A//                        final JsonSerializationContext jsonSerializationContext) %7B%0A//                    JsonObject jsonObject = new JsonObject();%0A//                    jsonObject.add(%22properties%22, jsonSerializationContext.serialize(documentProperties.()));%0A//                    return jsonObject;%0A//                %7D%0A//%0A//            %7D;%0A%0A
     

Remove commented lines