class FunctionPhaseSerializer extends JsonSerializer<FunctionPhase>
{
private void writePhaseFunction(JsonGenerator jg, FunctionPhase phase) throws IOException
{
Function function = phase.getFunction();
jg.writeStartObject();
jg.writeStringField("language", function.isJavascript() ? "javascript" : "erlang");
if (function.isJavascript())
{
if (function.isNamed())
{
jg.writeStringField("name", function.getName());
} else if (function.isStored())
{
jg.writeStringField("bucket", function.getBucket());
jg.writeStringField("key", function.getKey());
} else if (function.isAnonymous())
{
jg.writeStringField("source", function.getSource());
} else
{
throw new IllegalStateException("Cannot determine function type");
}
} else if (!function.isJavascript())
{
jg.writeStringField("module", function.getModule());
jg.writeStringField("function", function.getFunction());
}
jg.writeBooleanField("keep", phase.isKeep());
jg.writeObjectField("arg", phase.getArg());