/**
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gravitee.definition.jackson.datatype.ser;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;
import io.gravitee.definition.model.Rule;

import java.io.IOException;

/**
 * @author David BRASSELY (brasseld at gmail.com)
 * @author Gravitee.io Team
 */
public class RuleSerializer extends StdScalarSerializer<Rule> {

    public RuleSerializer(Class<Rule> t) {
        super(t);
    }

    @Override
    public void serialize(Rule rule, JsonGenerator jgen, SerializerProvider provider) throws IOException {
        jgen.writeStartObject();

        jgen.writeFieldName("methods");
        jgen.writeObject(rule.getMethods());

        jgen.writeObject(rule.getPolicy());

        jgen.writeEndObject();
    }
}

@@ -678,16 +678,131 @@
 e.ser;%0A%0A
+import io.gravitee.common.http.HttpMethod;%0Aimport io.gravitee.definition.model.Rule;%0A%0Aimport java.io.IOException;%0A%0A
 import c
@@ -970,79 +970,8 @@
 zer;
-%0Aimport io.gravitee.definition.model.Rule;%0A%0Aimport java.io.IOException;
 %0A%0A/*
@@ -1382,16 +1382,25 @@
 hods%22);%0A
+        %0A
         
@@ -1413,32 +1413,176 @@
 rite
-Object(rule.getMethods()
+StartArray();%0A        for (HttpMethod method : rule.getMethods()) %7B%0A            jgen.writeString(method.toString().toUpperCase());%0A        %7D%0A        jgen.writeEndArray(
 );%0A%0A

modify RuleSerializer to capitalize HttpMethod, usefull to compare JSON between EventPayload and API