mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-30 02:55:27 +03:00
24 lines
771 B
Java
24 lines
771 B
Java
package pro.gravit.launcher.request;
|
|
|
|
import java.lang.reflect.Type;
|
|
|
|
import com.google.gson.JsonElement;
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonPrimitive;
|
|
import com.google.gson.JsonSerializationContext;
|
|
import com.google.gson.JsonSerializer;
|
|
|
|
public class JsonResultSerializeAdapter implements JsonSerializer<WebSocketEvent> {
|
|
private static final String PROP_NAME = "type";
|
|
|
|
@Override
|
|
public JsonElement serialize(WebSocketEvent src, Type typeOfSrc, JsonSerializationContext context) {
|
|
// note : won't work, you must delegate this
|
|
JsonObject jo = context.serialize(src).getAsJsonObject();
|
|
|
|
String classPath = src.getType();
|
|
jo.add(PROP_NAME, new JsonPrimitive(classPath));
|
|
|
|
return jo;
|
|
}
|
|
}
|