class MessageTypeAdapter extends TypeAdapter<Message> {
   public static final TypeAdapterFactory MESSAGE_TYPE_ADAPTER_FACTORY = new TypeAdapterFactory() {
        public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
            if (type.getRawType() != Message.class) {
                return null;
            } else {
                TypeAdapter<Message> delegate = (TypeAdapter<Message>) gson.getDelegateAdapter(this, type);
                return (TypeAdapter<T>) new MessageTypeAdapter(delegate);
            }
        }
    };
    private final TypeAdapter<Message> delegate;

    private MessageTypeAdapter(TypeAdapter<Message> delegate) {
        this.delegate = delegate;
    }

    public void write(JsonWriter out, Message message) throws IOException {<FILL_FUNCTION_BODY>}

    public Message read(JsonReader in) throws IOException {
        return (Message)this.delegate.read(in);
    }
}

        out.beginObject();
        out.name("role");
        out.value(message.role().toString());
        out.name("content");
        if (message.content() == null) {
            boolean serializeNulls = out.getSerializeNulls();
            out.setSerializeNulls(true);
            out.nullValue();
            out.setSerializeNulls(serializeNulls);
        } else {
            out.value(message.content());
        }

        if (message.name() != null) {
            out.name("name");
            out.value(message.name());
        }

        if (message.functionCall() != null) {
            out.name("function_call");
            TypeAdapter<FunctionCall> functionCallTypeAdapter = Json.GSON.getAdapter(
                    FunctionCall.class);
            functionCallTypeAdapter.write(out, message.functionCall());
        }

        out.endObject();
    
<no_super_class>