package cn.orionsec.ops.constant.event;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import cn.orionsec.kit.lang.utils.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.junit.Test;

import java.util.LinkedHashMap;

public class EventTypeTest {

    @Test
    public void generatorEnumJson() {
        EventType[] values = EventType.values();
        LinkedHashMap<String, EventTypeTest.EventTypeJson> map = Maps.newLinkedMap();
        for (EventType value : values) {
            map.put(value.name(), new EventTypeTest.EventTypeJson(value.getType(), value.getLabel(), value.getClassify().getClassify()));
        }
        System.out.println(JSONArray.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.MapSortField));
    }

    @Data
    @AllArgsConstructor
    static class EventTypeJson {

        @JSONField(ordinal = 0)
        private Integer value;

        @JSONField(ordinal = 1)
        private String label;

        @JSONField(ordinal = 2)
        private Integer classify;

    }

}
