package com.rollbar.payload.utilities;

import com.google.gson.JsonElement;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.rollbar.payload.data.body.Body;
import sun.misc.Regexp;

import java.lang.reflect.Type;
import java.util.HashMap;

public class BodyAdapter  implements JsonSerializer<Body> {
    public JsonElement serialize(Body body, Type type, JsonSerializationContext jsonSerializationContext) {
        HashMap<String, Object> toSerialize = new HashMap<String, Object>();
        toSerialize.put(toSnakeCase(body.contents().getClass().getSimpleName()), body.contents());
        return jsonSerializationContext.serialize(toSerialize);
    }

    public String toSnakeCase(String simpleName) {
        return String.join("_", simpleName.split("(?=\\p{Lu})")).toLowerCase();
    }
}

@@ -203,32 +203,8 @@
 ody;
-%0Aimport sun.misc.Regexp;
 %0A%0Aim
@@ -263,67 +263,419 @@
 p;%0A%0A
-public class BodyAdapter  implements JsonSerializer%3CBody%3E %7B
+/**%0A * A JsonSerializer that serializes the %7B@link Body%7D.%0A */%0Apublic class BodyAdapter  implements JsonSerializer%3CBody%3E %7B%0A    /**%0A     * Serializes the body for GSON (names the %60content%60 with snake_case, based on its class name).%0A     * @param body the body to serialize%0A     * @param type the type being serialized%0A     * @param jsonSerializationContext the context doing the serializing%0A     * @return%0A     */
 %0A   
@@ -1031,19 +1031,27 @@
 %7D%0A%0A    p
-ubl
+rivate stat
 ic Strin

Document BodyAdapter