package net.kencochrane.raven.marshaller.json;

import com.fasterxml.jackson.core.JsonGenerator;
import net.kencochrane.raven.event.interfaces.MessageInterface;

import java.io.IOException;

public class MessageInterfaceBinding implements InterfaceBinding<MessageInterface> {
    private static final String MESSAGE_PARAMETER = "message";
    private static final String PARAMS_PARAMETER = "params";

    @Override
    public void writeInterface(JsonGenerator generator, MessageInterface messageInterface) throws IOException {
        generator.writeStartObject();
        generator.writeStringField(MESSAGE_PARAMETER, messageInterface.getMessage());
        generator.writeArrayFieldStart(PARAMS_PARAMETER);
        for (String parameter : messageInterface.getParams()) {
            generator.writeString(parameter);
        }
        generator.writeEndArray();
        generator.writeEndObject();
    }
}

@@ -269,16 +269,124 @@
 face%3E %7B%0A
+    /**%0A     * Maximum length for a message.%0A     */%0A    public static final int MAX_MESSAGE_LENGTH = 1000;%0A
     priv
@@ -502,16 +502,499 @@
 rams%22;%0A%0A
+    /**%0A     * Formats a message, ensuring that the maximum length %7B@link #MAX_MESSAGE_LENGTH%7D isn't reached.%0A     *%0A     * @param message message to format.%0A     * @return formatted message (shortened if necessary).%0A     */%0A    private String formatMessage(String message) %7B%0A        if (message == null)%0A            return null;%0A        else if (message.length() %3E MAX_MESSAGE_LENGTH)%0A            return message.substring(0, MAX_MESSAGE_LENGTH);%0A        else return message;%0A    %7D%0A%0A
     @Ove
@@ -1203,16 +1203,30 @@
 AMETER, 
+formatMessage(
 messageI
@@ -1247,16 +1247,17 @@
 ssage())
+)
 ;%0A      

Set a maximum size for the Message interface